slevithan / regex

Regex template tag for readable, high-performance, native JS regexes, with context-aware interpolation and always-on best practices
MIT License
482 stars 9 forks source link

SyntaxError: Invalid regular expression: invalid group specifier name #26

Open unclekitty opened 19 hours ago

unclekitty commented 19 hours ago

SyntaxError in src/subroutines.js

const subroutinePattern = String.raw`\\g<(?<subroutineName>[^>&]+)>`;
const token = new RegExp(String.raw`
${subroutinePattern}
| (?<capturingStart>${capturingDelim})
| \\(?<backrefNum>[1-9]\d*)
| \\k<(?<backrefName>[^>]+)>
| \\?.
`.replace(/\s+/g, ''), 'gsu');

Safari browser Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko

slevithan commented 18 hours ago

Thanks for the report!

Can you provide more details? I'm not easily able to test Safari.

It's not at all obvious why that code would trigger a syntax error, and obviously it is passing the tests in recent versions of Node.js, etc.