Can the second parameter of a RegExp be to match the whole word that is given in the first parameter?
new RegExp(words, `g`)
I have tried everything but it does not work. Does someone know how to make this happen?
UPDATE:
I have a list of words that I want to match in a paragraph. I use .replace(/\b(dog|cat|pet)/gi, replaceWords) to match exactly the words in the first parameter.
The problem is is that I have more then 300 words. How can I make the RegExp match the whole word in the second parameter?