My app will not boot, it will break with the exception:
Invalid regular expression: invalid group specifier name
no stack
run
NativeRunnable.java
handleCallback
Handler.java:873
dispatchMessage
Handler.java:99
dispatchMessage
MessageQueueThreadHandler.java:29
loop
Looper.java:209
run
MessageQueueThreadImpl.java:232
run
Thread.java:914
I found that in iOS or android, if I enabled live javascript debug, then the problem will not occur, but why?
The same error I got on xcode and android:
no stack', reason: 'Unhandled JS Exception: Invalid regular expression: invalid group specifier name
I have no idea where to dig? or where to debug? Any one can help?
The JavaScript exception "invalid regular expression flag" occurs when the flags, defined after the second slash in regular expression literal, are not one of g, i, m, s , u, or y. What went wrong? There are invalid regular expression flags in the code.
The "Invalid regular expression: Range out of order in character class" error occurs when we forget to escape a hyphen in a character class in a regular expression. To solve the error, specify the hyphen as the first or last character in the regex or escape it.
This error occurs very often when using regex strings, which are quite more difficult to debug as IDE support is minimal. To solve the error, you can either add the hyphen as the first or last character in the character class or escape it. Copied!
Ran into this as well, porting an electron project over to RN. Tracked it down to a lookbehind regular expression, which is supported in Chrome but not Safari (and, apparently, react native) -- see Works in Chrome, but breaks in Safari: Invalid regular expression: invalid group specifier name /(?<=\/)([^#]+)(?=#*)/
Searching for (?
in my project led me right to the culprit!
The reason you don't get a stack with this error is because regular expression literals in JavaScript are compiled before the script is executed.
Regular expression literals provide compilation of the regular expression when the script is loaded.
– MDN - Regular Expressions
Unfortunately, this means that the offending regular expression might be anywhere in your code, since all the ES2015 modules are bundled together in react-native applications.
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