Lookbehind Javascript Regexp
I'm trying to replace some string using pattern but I have no idea how to check if there is dot before string. It should be negative for .some and positive for some var a = 'some.s
Solution 1:
As Javascript hasn't lookbehinds implemented you can match it normally and replace the preceding character with itself with a backreference: a = a.replace(new RegExp("([^\.]|^)some\.string", "g"), "$1replaced");
Post a Comment for "Lookbehind Javascript Regexp"