-
Notifications
You must be signed in to change notification settings - Fork 113
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
Mistmatch on (A|B) when A is a prefix of B #12
Comments
From pcre specification (emphasis mine):
I checked RegExps in Firefox, Chrome, CPython, and Ack, and they work the same way. Grep did find the longest, though. But overall I think this is the expected behavior. |
A little variation on this: IMHO the pattern "^(y|yes|YES|Yes|true|TRUE|True)$" should match string "yes" but it does not. If the pattern is rearranged "^(yes|y|YES|Yes|true|TRUE|True)$" then it matches. I quickly checked with Regex Buddy and none of the supported regex flavours show this behaviour. |
I am happy to accept a PR with the associated unit test :) |
Not a big issue in my project, since I have control over the regexes. Just thought I let you know. If a project uses SLRE for user supplied regexes the result might be unexpected. |
Hiho,
i'm not sure if this qualifies as a bug, a corner case, or a known limitation:
regex: (match|matchAll)
input: match matchAll
when looping, that will match twice with these strings: ["match", "match"]
If the regex order is swapped, so that A is not a prefix of B (matchAll|match), then the result is as expected: ["match", "matchAll"].
Maybe a note in the docs suffices to cover this (maybe there is already one i overlooked).
The text was updated successfully, but these errors were encountered: