I want to catch word in paragraphy. I do not want to use word boundary because of unicode character (şöüİıçğ) problems. So I use a regex like this. I get an error Invalid group. Is there someone who can help?
var paragraphy= "Bu örnek bir metindir <span>bu</span> metin; test amaçlı yazılmıştır.";
var word="metin;";
var regex = new RegExp("([\\s>]|^)("+word+")(?=([\\.\\,\\;\\?\\!](?=[\\s<])|(?<![\\.\\,\\;\\?\\!])[<\\s]|$))", "gi");
console.log(paragraphy.match(regex));
I want to this result: ["metin"]
(?<!...)is a negative lookbehind and JS doesn't support it.(?:[\s>]|^)(metin)(?=[.,;?!]?(?:[<\s]|$))work for you?