I am mapping through a list of words (with random characters too) and the regex doesn't seem to work and ends up throwing an error.
I basically have a const variable (called content
)
I want to search to see if there are certain words in the content
variable.
so I have
if (list.words.map(lword=> {
const re = new RegExp("/" + lword+ "\\/g");
if (re.test(content)) {
return true;
}
}
But that just fails out and doesn't catch anything. I get a Nothing to repeat
error.
Specifically: Uncaught SyntaxError: Invalid regular expression: //Lu(*\/g/: Nothing to repeat
I'm not sure how to search through content
to see if it contains lword
.