Open subtleGradient opened 3 weeks ago
What errors or problems are you seeing when running regex
in React Native?
regex
's core processing relies on a few somewhat-modern regex features that the Hermes document you quoted claims to support -- things like ES6/ES2015's u
flag and ES9/ES2018's named capture and lookbehind. It also uses ES2018's s
flag, which is not mentioned. But I don't see any fundamental issue (apart from lack of support for s
, or potential Hermes bugs / divergences from the ES RegExp spec) that would prevent it from working.
Lack of flag s
would be disappointing (hopefully that's just an omission in the docs), but could be worked around. Swapping .
with [^]
in the core code would be trivial, but it would require a bit more work in regex-utilities.
Note that, a few days ago, Hermes 0.13.0 added support for ES2018's Unicode properties (\p{...}
), and the Hermes version was bumped to include this in React Native 0.75.1. Can you check if it works in RN 0.75.1 or later?
I'll check again once we upgrade to 75
Cool, thanks! I'd be very happy to see regex
working in React Native 0.75.1+, but I have zero experience with RN so any and all help with identifying/reproducing issues would be super helpful. The prior version of Hermes (0.12.0) is from 2 years ago, so it probably makes sense to limit support to RN 0.75.1+.
Without knowing what error you ran into, another possibility for the source of the problem is that Hermes (or at least older versions of it) doesn't support some other modern JS feature, unrelated to regexes. In regex
's source, I've tried to limit to JS features supported in Node.js 14 and 2020-era browsers, but this includes the use of features like private class properties, string matchAll
, array flatMap
, and the ??
and ?.
operators.
Not sure what it would take to make it work on RN in Hermes. https://github.com/facebook/hermes/blob/main/README.md
https://github.com/facebook/hermes/blob/73cb6664fe233150e1313553a135ffc472c16227/doc/RegExp.md