Skip to content
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

Java: Understand multiple parse mode flags specified in a regular expression string #13778

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

geoffw0
Copy link
Contributor

@geoffw0 geoffw0 commented Jul 20, 2023

Understand / correctly parse multiple parse mode flags specified in a regular expression string, for example i and s in:

(?is)abc.*

Previously we were only recognizing the first flag (i).

This is a backport of part of the Swift PR #13715 .

@geoffw0 geoffw0 added the Java label Jul 20, 2023
@geoffw0 geoffw0 requested a review from a team as a code owner July 20, 2023 11:02
@atorralba
Copy link
Contributor

Changes look plausible to me.

However, there's this test expectation diff:

--- expected
+++ actual
@@ -118,8 +118,9 @@
 | Test.java:16:95:16:101 | t{,15}+ | [RegExpQuantifier] |
 | Test.java:16:102:16:102 | u | [RegExpConstant,RegExpNormalChar] |
 | Test.java:16:102:16:108 | u{16,}+ | [RegExpQuantifier] |
-| Test.java:17:10:17:13 | (?i) | [RegExpZeroWidthMatch] |
+| Test.java:17:10:17:13 | (?i) | [RegExpGroup] |
 | Test.java:17:10:17:36 | (?i)(?=a)(?!b)(?<=c)(?<!d)+ | [RegExpSequence] |
+| Test.java:17:12:17:12 | i | [RegExpConstant,RegExpNormalChar] |
 | Test.java:17:14:17:18 | (?=a) | [RegExpPositiveLookahead] |
 | Test.java:17:17:17:17 | a | [RegExpConstant,RegExpNormalChar] |
 | Test.java:17:19:17:23 | (?!b) | [RegExpNegativeLookahead] |

I get the change from RegExpZeroWidthMatch to RegExpGroup, but the fact that the i gets classified as a RegExpConstant/RegExpNormalChar kind of bugs me. Happy to accept the changes if they look good to you though, just wanted to double check.

@geoffw0
Copy link
Contributor Author

geoffw0 commented Jul 21, 2023

the fact that the i gets classified as a RegExpConstant/RegExpNormalChar kind of bugs me.

I'm not sure of the right way to fix this. Add flagGroup to the zeroWidthMatch predicate???

@atorralba
Copy link
Contributor

I'm not sure of the right way to fix this. Add flagGroup to the zeroWidthMatch predicate???

🤷 not sure if it's even a problem. @erik-krogh any insight? Can we safely merge this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants