Perl: the Markov chain saw | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I don't understand the purpose of the (*FAIL) operator (see Special Backtracking Control Verbs in perlre in Perl versions 5.10+ (update: see also Backtracking control verbs in perlretut - but that's not actually as extensive as the discussion in perlre)) in the quoted regex. At any position in the | alternation, (*FAIL) will simply force the RE to try the next alternation; if it's at the last position, all the preceding pattern matches would have failed and the alternation would fail anyway without (*FAIL). Note that for all these variations, for string 'XXX' there is never a match (!~ is always true); string 'ppp' always matches (!~ always false). ... not equivalently, because there are 8 capturing groups instead of 2 ... If you're using (*FAIL) you must be using Perl version 5.10+, so you also have the (?|pattern) "branch reset" operator (see Extended Patterns in perlre). This allows you to go back to having two capture groups again! Update: Changed example code slightly to better reflect discussion. Give a man a fish: <%-{-{-{-< In reply to Re^6: regex return true instead of false (precedence)
by AnomalousMonk
|
|