0

I am trying to match content on variable c to variable s and selecting the match but all I get is a black bracket or it repeats variable c.

var s = "flowing through a lava occasionally";
var c = "occasionally, sleep, and, oops";
var re = /(?:^|\W)c(\w+)(?!\w)/g, match, matches = [];
while (match = re.exec(s)) {
  matches.push(match[3]);
}
console.log(matches);
halfer
  • 19,824
  • 17
  • 99
  • 186
woooooshh
  • 27
  • 1

0 Answers0