slevithan/xregexp

Does not polyfill negative lookbehind in Safari

kettanaito opened this issue ยท 1 comments

Hey ๐Ÿ‘‹

Thanks for writing this library.

I'm trying to use it to polyfill some of the missing RegExp features in Safari, like negative lookbehind.

Steps to reproduce

import XRegExp from "xregexp";

console.log(XRegExp("/\r(?!\n)|(?<!\r)\n/"));

Result in Safari:

Invalid regular expression: invalid group specifier name

โ€” Open in CodeSandbox

I believe this is caused by new RegExp(generated.pattern, ...) constructor in the source of xregexp. It looks like it constructs a new RegExp, using the native class, providing it with the unsupported pattern string in Safari.

Expected behavior

I'd expect negative lookbehind to work in Safari. Let me know if I understood the intention behind this library wrong.

Found #77. I suppose that closes this one.