-
Notifications
You must be signed in to change notification settings - Fork 396
Matcher.groupCount behaviour inconsistent between JS and JVM #3280
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
Comments
Indeed, we need an existing match in JS to be able to obtain the group count. We could invent a matching string to produce a match, but producing such a string is non-trivial. However, we could in theory do a shallow parse of the regex to count the number of non-capturing groups. I'll leave that open and up for grabs by the community. |
Since |
PR welcome 🙂 |
PR to master or 0.6.x? I am not sure if fix of this is breaking change. I can imagine that there is code somewhere in dark corner of the Galaxy that uses exception from calling groupCount to check, if find has been already called or not, calling find in catch and retrying. |
0.6.x. It doesn't matter that it could be breaking someone's code, since we're aligning with the JVM. That always goes to 0.6.x. |
…ount Fix #3280: Count capturing groups independently on find.
Fixed in e5d3d6b. |
The following works fine under both platforms:
The following fails in
js
but notjvm
:There's nothing in the
Matcher
scaladoc that seems to imply that callingfind
beforegroupCount
is needed.It does, however, seem like an unfixable bug. I'm no javascript expert, but it does rather look that regexes can only expose the group count for a given match, not for a matcher.
The text was updated successfully, but these errors were encountered: