You cannot use look-backs in JavaScript, but you can use advances.
So this will give false:
As for the look, in most cases you can get around this limitation by using capture groups, return lines and matches, or by creating your own parsers.
Here is a way to combine /win/i.test(string) && !/cyg win/i.test(string):
document.write(/niw(?!\s+gyc\b)/.test('cyg win'.split("").reverse().join("")));
document.write("<br/>");
document.write(/niw(?!\s+gyc\b)/.test('darwin'.split("").reverse().join("")));
Run codeHide resultNote that the - niw(?!\s+gyc\b)- pattern must be canceled.
source
share