-
Notifications
You must be signed in to change notification settings - Fork 89
Support \u{HEX} syntax in ECMAScript with Unicode flag #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
This was found by a user of a project I worked on and the original regexp is a lot more ... involved and is here. I would like also the input of @dop251 (sorry about pinging you), as I am using this library through goja. I don't think this should be "fixed" goja though, but maybe I have missed something. |
|
It appears the \x{hex} syntax is widely supported across regex engines. I suggest we change this PR to just add support for it without needing a specific flag. Thoughts? It’s a syntax error in .NET but I’m fine allowing new syntax as long as existing .NET patterns work in the engine. |
|
I'm not sure about other modes, but as far as I'm aware the (Note for @dlclark, the |
|
@dlclark I also couldn't find this to be a syntax anywhere else ... but to be honest googling @dop251 I originally saw it is required from https://exploringjs.com/es6/ch_unicode.html#_where-can-escape-sequences-be-used And couldn't really find good reference in the actual specification. Now that I tried again I found https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html#_ref_20735 seems like the unicode escapes at all should only work when |
|
Yes, you're right, my bad. |
|
Ha, in my head I apparently just switched to \x instead of \u. Ignore my previous comment. The only other thing I’d ask is some documentation in the readme about what the new Unicode option does. |
|
I triple checked on firefox, gjs and nodejs they have the behaviour explained in the first link I gave. Looking at the specification more closely I just now realised that next to one of the lines there is ? and the other is + 🤦 So yes this is more or less the expected behaviour. There seem to be more cases to be implemented but this is the one I have hit so lets have only this for now 😬
will try to come up with something, but it likely will be "enables ECMAScript's unicode mode, has no effect without ECMAScript mode enabled as well" |
No description provided.