In my Javascript code, this regex /(?<=\/)([^#]+)(?=#*)/
works fine in Chrome, but in safari, I get:
Invalid regular expression: invalid group specifier name
Any ideas?
Looks like Safari doesn't support lookbehind yet (that is, your (?<=\/)
). One alternative would be to put the /
that comes before in a non-captured group, and then extract only the first group (the content after the /
and before the #
).
/(?:\/)([^#]+)(?=#*)/
Also, (?=#*)
is odd - you probably want to lookahead for something (such as #
or the end of the string), rather than a *
quantifier (zero or more occurrences of #
). It might be better to use something like
/(?:\/)([^#]+)(?=#|$)/
or just omit the lookahead entirely (because the ([^#]+)
is greedy), depending on your circumstances.
Just wanted to put this out there for anyone who stumbles across this issue and can't find anything...
I had the same issue, and it turned out to be a RegEx expression in one of my dependencies, namely Discord.js .
Luckily I no longer needed that package but if you do, consider putting an issue out there or something (maybe you shouldn't even be running discord.js in your frontend react app).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With