I can't figure out why rg = new RegExp(`/${a}.*${b}/`)
isn't functioning properly here, while rg = /\(.*\)/
is working fine.
let a = '\(';
let b = '\)';
let rg;
//rg = new RegExp(`/${a}.*${b}/`); // doesn't work
rg = /\(.*\)/;
let match = rg.exec(`test (regex works) is ok`);
if (match) {
console.log(match[0]); // -> (regex works)
}