Hermes: Regex causes "Quantifier has nothing to repeat"

Created on 17 Jul 2019  路  3Comments  路  Source: facebook/hermes

I've tested this against the non-hermes version and it works fine. It seems that when I attempt to use my regex string it crashes the app:

Invalid regular expression: Quantifier has nothing to repeat, js engine: hermes

I have an example application here: https://github.com/Kikketer/HermesRejex/blob/master/App.js#L22

It's very simple in the fact that it attempts to run a rejex against a string when you tap the "Hi There" text.

The simple app is right out of the react-native init except that it has hermes enabled and this new tap functionality.

Also since reading regex can be painful, the string this matches would be:

{{date(2019-07-17T14:57:33.780Z, short)}}

Most helpful comment

Hermes does not yet support named capture groups in RegExp. We're adding newer JS features incrementally and named capture groups will be implemented in the future. Unfortunately, priority for this particular feature is low because we have other features to implement first, but we're open to working with the community on pull requests to add it.

You can see more information about RegExp support here:
https://github.com/facebook/hermes/blob/master/doc/RegExp.md

All 3 comments

I've discovered the issue, I needed to add some "seemingly useless" escapes. Just a challenge with different regex parsers:

/{{2}/

turned to:

/\{{2}/

Fixes the issue. Just something to note for any other developer out there that has some regex and it's only failing on Hermes.

For me, i encountered an error when use named capturing group in regex

(?<Name>x)

Hermes does not yet support named capture groups in RegExp. We're adding newer JS features incrementally and named capture groups will be implemented in the future. Unfortunately, priority for this particular feature is low because we have other features to implement first, but we're open to working with the community on pull requests to add it.

You can see more information about RegExp support here:
https://github.com/facebook/hermes/blob/master/doc/RegExp.md

Was this page helpful?
0 / 5 - 0 ratings