I'm trying to make a RegEx that can single out words from a string but ignore them if they're inside a tag. For example: Even though the searchword is SPAN, do not replace a span tag.
What I have so far is:
(?<![<\/])\bspan\b(?!>)
Span obviously is a placeholder. In the script it is generated from a dictionary dynamically.
This is what I'm trying to run:
var reg = new RegExp(the expression, 'gi');
I've escaped the /, so I'm not sure where the problem is.
And this is what I get back: SCRIPT5018: Unexpected quantifier
Any help would be appreciated. I made the Regular Expression with the help of regex101.com.