react-native icon indicating copy to clipboard operation
react-native copied to clipboard

react native is not excepting positive/negative lookbehinds as valid regex

Open SyntappZ opened this issue 3 years ago • 4 comments

Description

in my app when trying to use positive/negative lookbehinds i get this error: invalid regular expression invalid group specifier name my main app is on react native 62 i have made an app for testing purposes and this is on the latest react native 63.4 and the error still persists, i think this is a bug but if not any help or advice on how to fix this would be greatly appreciated.

React Native version:

System: OS: Windows 10 10.0.19041 CPU: (8) x64 Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz Memory: 11.31 GB / 15.94 GB Binaries: Node: 12.18.2 - C:\Program Files\nodejs\node.EXE Yarn: Not Found npm: 6.14.11 - C:\Program Files\nodejs\npm.CMD Watchman: Not Found SDKs: Android SDK: API Levels: 23, 26, 28, 29, 30 Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.1 System Images: android-23 | Google APIs Intel x86 Atom, android-25 | Google Play Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom_64 Android NDK: Not Found Windows SDK: Not Found IDEs: Android Studio: Not Found Visual Studio: Not Found Languages: Java: 1.8.0_271 - /c/Program Files/Java/jdk1.8.0_271/bin/javac Python: 2.7.3 - /c/Python27/python npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: 0.63.4 => 0.63.4 react-native-windows: Not Found npmGlobalPackages: react-native: Not Found

Steps To Reproduce

I have added a test app repo for testing. i have added 9 test buttons and only the lookbehinds fail.

  1. press the quick test buttons for a quick test or type your own regex in the input to test.
  2. to get the error and call stack turn off the safety switch.

Expected Results

I expected for the regex to be valid

Snack, code example, screenshot, or link to a repository:

testing repo - https://github.com/SyntappZ/react-native-regex-testing

SyntappZ avatar Jan 09 '21 17:01 SyntappZ

@SyntappZ Thank you for the repo example! Great UI on it.

Screen Shot 2021-01-09 at 9 29 41 AM

It seems weird that a valid regex expression does not validate correctly on React Native. This is definitely an issue, nice catch. Added the appropriate labels

safaiyeh avatar Jan 09 '21 17:01 safaiyeh

@safaiyeh Thanks mate 🙂

SyntappZ avatar Jan 09 '21 19:01 SyntappZ

Is there any update on this. I'm facing the same issue is react native version 0.68.2.

saurabhbh21 avatar Jun 30 '22 03:06 saurabhbh21

The issue is lookbehind regex is not supported in JSC (which is JS compiler in RN). Replacing JSC with Hermes fixed the issue for me.

saurabhbh21 avatar Aug 23 '22 03:08 saurabhbh21