Passing a variable into a JavaScript RegExp method

How can I pass a variable into a JavaScript RegExp match method?
I have this code:

let rgx = new RegExp(/(?<= )(word1|word2|word3)(?= )/).source;
Code (markup):

What I'd like to […]

See original post by invalid@example.com (Alex100)

Leave a Reply