I have this ReGex string to catch anything that starts with go/
in a sentence:
/\bgo/i
It works great. However, the word go
can change so I want to include a variable inside it so I moved it to RegExp
like so:
const variable = 'go';
const rex = new RegExp(`/\b${variable}/`, 'i');`
However, it doesn't seem to work, I'm not sure why. I even tried removing the start/end sequence characters but it still doesn't work.
new RegExp(`\\b${variable}`, 'i');
. - iz_