I am trying to insert a variable into a regex statement
However for some reason
all the methods I found didnt work with this particular statement
This code works perfectly fine and return true
const regex = /byoub/i;
const str = 'How are you today?';
console.log(regex.test(str));
const strInsert = "you"
const regex = new RegExp(`/{strInsert}b/i`);
const str = 'How are you today?';
console.log(regex.test(str));
I attempted to do the following
However this resulted in an output of false when it should be true