I don't understand why rg = new RegExp(`/${a}.*${b}/`)
doesn't work below whereas rg = /\(.*\)/
does work.
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)
}