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
(*COMMIT) behaviour when inside a repeated group #17074
Comments
From ph10@hermes.cam.ac.ukCreated by ph10@cam.ac.ukPlease see the following example: $ perl -e 'if (abcd =~ /\A(?:.(*COMMIT))*c/) { print "yes >$&<\n"; } else { print "no \n"; }' Why does that pattern match? The repeated group should swallow all of "abcd", Philip Perl Info
|
From @demerphqOn Tue, 2 Jul 2019 at 11:17, Philip Hazel (via RT)
Well I have to admit its a bit murky, but I think the match should From the docs: In this case technically we never backtracked into the COMMIT, and we Yves |
The RT System itself - Status changed from 'new' to 'open' |
From ph10@hermes.cam.ac.ukOn Tue, 2 Jul 2019, yves orton via RT wrote:
Hmm. I can now see that there is an alternative interpretation of $ perl -e 'if (abcd =~ /.*(*COMMIT)c/) { print "yes >$&<\n"; } else { print "no \n"; }' Incidentally, the \A at the start of my previous example is not /.*(*COMMIT)c/ does not match "abcd" Under your interpretation, shouldn't the first one match? After all, it
As an outsider looking at Perl, I don't understand that. I thought that
I await the ruling! Regards, -- |
From @demerphqOn Tue, 2 Jul 2019 at 16:44, <ph10@hermes.cam.ac.uk> wrote:
No, because this one definitely DOES backtrack into into the COMMIT
Because the * is on a group, the group is rolled back as a group, so
Again no, because it backtracks into the (*COMMIT). I am not saying
Because (?:...)* is compiled into a construct called CURLYM which does The problem I think is that there is a clash between the purist DFA Lets just take a simple case: "aaab"=~/a*x/ The rules dont really specify if we ever actually "fail to match" with You can say that "a*" matches the first three a's and then fails on BUT There is another equally valid interpretation that a* matches ONLY the IOW, we would have a state machine like this: / Input This machine would never backtrack on "aaab"=~/a*x/; So at a certain level it doesn't surprise me that we show both Yves |
From ph10@hermes.cam.ac.ukOn Tue, 2 Jul 2019, yves orton via RT wrote:
Yves, Thanks for taking the time to explain all this to me. So if
But surely there can be backtracks into other things in a group? How
I've tried to avoid learning anything about Perl internals :-) but
Understood.
Indeed! These are are very pathological examples.
Indeed again. Regards, -- |
Migrated from rt.perl.org#134254 (status was 'open')
Searchable as RT134254$
The text was updated successfully, but these errors were encountered: