-
Notifications
You must be signed in to change notification settings - Fork 662
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
hasIndices flag for regex #932
Labels
enhancement
New feature or request
Comments
53 tasks
facebook-github-bot
pushed a commit
that referenced
this issue
Aug 29, 2023
Summary: This change adds support for `hasIndices` RegExp flag, according to ES2022 specifications. References: https://262.ecma-international.org/13.0/#sec-regexp-regular-expression-objects https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/hasIndices This change is also related to this issue: #932 Pull Request resolved: #968 Test Plan: ``` javascript var str = "The Quick Brown Fox Jumps Over The Lazy Brown Dog"; var regex = /quick\s(?<color>brown).+?(?<action>jumps).+?(?<where>over_)*/dgi; var res = regex.exec(str); print(Object.getOwnPropertyNames(res)); // 0,1,2,3,length,index,input,groups,indices print(Object.getOwnPropertyNames(res.indices)); // 0,1,2,3,length,groups print(res.indices[0]); // 4,26 print(res.indices[1]); // 10,15 print(res.indices[2]); // 20,25 print(res.indices[3]); // undefined print(Object.getOwnPropertyNames(res.indices.groups)); // color,action,where print(res.indices.groups.constructor); // undefined print(res.indices.groups.color); // 10,15 print(res.indices.groups.action); // 20,25 print(res.indices.groups.where); // undefined ``` Reviewed By: neildhar Differential Revision: D48396577 Pulled By: fbmal7 fbshipit-source-id: 11f2e52630d3ddbc7e34c3cdbcc80849df458bc5
This was implemented in #968 and should land in the next hermes release I think? |
2afc7b0 does not appear to be included in a release yet, but hopefully soon 🙂 |
@roryabraham This feature will be in RN 0.73. |
facebook-github-bot
pushed a commit
that referenced
this issue
Nov 8, 2023
Summary: Original Author: contact@fabiohenriques.dev Original Git: 2afc7b0 Original Reviewed By: neildhar Original Revision: D48396577 This change adds support for `hasIndices` RegExp flag, according to ES2022 specifications. References: https://262.ecma-international.org/13.0/#sec-regexp-regular-expression-objects https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/hasIndices This change is also related to this issue: #932 Pull Request resolved: #968 Pulled By: fbmal7 Reviewed By: tmikov, neildhar Differential Revision: D50992837 fbshipit-source-id: 6c29b930fcc17957b95fe049afc190cfc840ff05
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem
We were trying to use a regex with the
-d
/hasIndices
flag, and noticed that it worked on web but not iOS/Android. I then discovered that it looks like this flag is just not yet implemented in the Hermes engine:hermes/include/hermes/Regex/RegexTypes.h
Lines 213 to 343 in 4171902
Solution
Implement the
-d
/hasIndices
flag for Hermes regex.Additional Context
Our use case for the
-d
flag is described hereThe text was updated successfully, but these errors were encountered: