A2Z-F21 icon indicating copy to clipboard operation
A2Z-F21 copied to clipboard

Regular Expression Example from class

Open shiffman opened this issue 4 years ago • 0 comments

const regex = /<p>(.*?)<\/p>/g;
const str = 'Hi <p>my name is</p> Dan and I am <p>teaching</p>.';

let matchInfo = regex.exec(str);
let matches = [];

while (matchInfo !== null) {
  matches.push(matchInfo[1]);
  matchInfo = regex.exec(str);  
}

console.log(matches);

shiffman avatar Sep 22 '21 20:09 shiffman