0

I assume these two are equivalent:

let pattern1 = /\((.?)*\)/g;
let pattern2 = new RegExp('\((.?)*\)', 'g');

but they produce different results when applied on the following string:

let str = 'abc(a, b);'
let result1 = str.match(pattern1);
let result2 = str.match(pattern2);

Why?

Arnold Zahrneinder
  • 4,788
  • 10
  • 40
  • 76

0 Answers0