slevithan / regex

JS regexes + future. A template tag for readable, high-performance, native JS regexes, with context-aware interpolation and always-on best practices.
MIT License
504 stars 9 forks source link

Bug: Named group matching not supported in Safari 15.5. #27

Open zhe-he opened 1 day ago

zhe-he commented 1 day ago

https://github.com/slevithan/regex/blob/ff7adf5a6f904b5c1c91a544efafb9c174e2baea/src/subroutines.js#L21C1-L28C1

I encountered a problem and found that Safari reported an error. Eventually, I pinpointed it to this location. In comparison to this, I wrote a simple regular expression. The image below shows the normal display and the error reported by Safari.

var capturingDelim = String.raw`\((?!\?)(?!(?<=\(\?\()DEFINE\))`;
new RegExp(String.raw`
| (?<capturingStart>${capturingDelim})
`.replace(/\s+/g, ''), 'gsu');
image image

I directly imported regex/dist/regex.min.js, and I still get the same error when I open it with Safari.

slevithan commented 1 day ago

Thanks for the report. Yes, this is a known issue. Old Safari is not supported, since Regex+ relies on lookbehind which Safari was years late to support compared to other browsers (not until Safari 16.4, released, released 2023-03-27).

I'll leave this open for now, until I investigate if there are things I can do to work around this.