Open p5pRT opened 11 years ago
I have been testing combinations of (*SKIP)\, (*PRUNE)\, etc to determine if there is any precedence when several of them are present. It seems that the rule is that whichever one is backtracked onto first does its thing\, and earlier ones are ignored. But there is one exception. Consider these two patterns when matched against "aaaaaac" (6 'a' characters plus 'c'):
/aaaaa(*SKIP)b|a+c/ /aaaaa(*PRUNE)b|a+c/
The first matches "ac" and the second "aaaac"\, entirely as expected. However\, if the patterns are changed to
/aaaaa(*COMMIT)(*SKIP)b|a+c/ /aaaaa(*COMMIT)(*PRUNE)b|a+c/
the first still matches "ac"\, but the second now gives "no match". In all other cases I have tried\, such as putting (*PRUNE) in front of (*SKIP) or vice versa\, and including tests with (*THEN)\, the insertion of the first verb makes no difference\, which is what I would expect if the rule is "first backtracked onto is activated".
Here is some evidence of these effects:
$ perl -e 'print (("aaaaaac" =~ /aaaaa(*SKIP)b|a+c/)? "$&\n":"no match\n");' ac $ perl -e 'print (("aaaaaac" =~ /aaaaa(*PRUNE)b|a+c/)? "$&\n":"no match\n");' aaaac $ perl -e 'print (("aaaaaac" =~ /aaaaa(*COMMIT)(*SKIP)b|a+c/)? "$&\n":"no match\n");' ac $ perl -e 'print (("aaaaaac" =~ /aaaaa(*COMMIT)(*PRUNE)b|a+c/)? "$&\n":"no match\n");' no match $
On Fri\, Mar 15\, 2013 at 7:18 AM\, Philip Hazel \perlbug\-followup@​perl\.orgwrote:
# New Ticket Created by Philip Hazel # Please include the string: [perl #117179] # in the subject line of all future correspondence about this issue. # \<URL: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=117179 >
Cc: nobody Subject: Regex: COMMIT+SKIP differs from COMMIT+PRUNE Message-Id: \5\.16\.2\_19279\_1363344286@​quercite Reply-To: ph10@hermes.cam.ac.uk To: perlbug@perl.org From: ph10@hermes.cam.ac.uk
This is a bug report for perl from ph10@hermes.cam.ac.uk\, generated with the help of perlbug 1.39 running under perl 5.16.2.
----------------------------------------------------------------- [Please describe your issue here]
I have been testing combinations of (*SKIP)\, (*PRUNE)\, etc to determine if there is any precedence when several of them are present. It seems that the rule is that whichever one is backtracked onto first does its thing\, and earlier ones are ignored. But there is one exception. Consider these two patterns when matched against "aaaaaac" (6 'a' characters plus 'c'):
/aaaaa(*SKIP)b|a+c/ /aaaaa(*PRUNE)b|a+c/
The first matches "ac" and the second "aaaac"\, entirely as expected. However\, if the patterns are changed to
/aaaaa(*COMMIT)(*SKIP)b|a+c/ /aaaaa(*COMMIT)(*PRUNE)b|a+c/
the first still matches "ac"\, but the second now gives "no match". In all other cases I have tried\, such as putting (*PRUNE) in front of (*SKIP) or vice versa\, and including tests with (*THEN)\, the insertion of the first verb makes no difference\, which is what I would expect if the rule is "first backtracked onto is activated".
(*COMMIT)'s or (*PRUNE)'s behaviour differs from their documentation. According to (*COMMIT) 's documentation\, it should do its thing "when backtracked into"\, but that can't happens when (*PRUNE) comes right after because "no further backtracking will take place" after backtracking into (*PRUNE).
The RT System itself - Status changed from 'new' to 'open'
Migrated from rt.perl.org#117179 (status was 'open')
Searchable as RT117179$