Im trying to replace words in a string which may have html tags or spaces. So if I want to find/replace Javascript:
var text = 'Java Javascript and <li>Javascript</li> javascript';
var find = "Javascript";
var regex = new RegExp(`(?:>|\s)(${find})(?:<|\s)`, "gi");
var result = text.replace(regex, 'JavascriptUpdated');
console.log(result, "result");
However its not finding the char space version and I dont want to replace "<" just allow it to find.
Im using "\s" to no find inside words, so if search was "Java" I dont want to find that in inside "Javascript"