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
regexp: CompilePOSIX does not appear to match leftmost-longest #9684
Comments
FWIW, the "normalized", though equal form
prints
|
AFAIK, match-group should work with specified order. not longest. At least, perl seems to work specified order. |
My understanding of POSIX leftmost-longest is that it should pick the longest possible alternative. Switching the alternatives in the example from this issue does make it pick a different alternative, which doesn't seem right. |
regexp engine of vim works as ordered. |
Yes, the leftmost-longest only applies to the overall match. Within the match, it is the "first match" semantics of Perl. When POSIX mandated the submatch leftmost-longest rule they had no idea how to implement it without exponential time. It's not trivial and not worth it. (It's possible but no one does except maybe Haskell.) |
Run the following program:
It prints:
I would expect it to print
choosing the longer of the two alternatives, as for example
acme's regexp engine does.
The text was updated successfully, but these errors were encountered: