This regex is supposed to capture what's after the =
sign and what's before the )
.
Why does it return both the = and ) in the output. Is this how it works? Or am I doing something wrong?
const s = '=foo)';
console.log(s.match(/=(.*)\)/g))
This regex is supposed to capture what's after the =
sign and what's before the )
.
Why does it return both the = and ) in the output. Is this how it works? Or am I doing something wrong?
const s = '=foo)';
console.log(s.match(/=(.*)\)/g))
If you don't need to match multiple instances and you want to get what's in the capturing group then you get get rid of the g
flag and retrieve solely the capturing group:
const s = '=foo)';
console.log(s.match(/=(.*)\)/)[1]);