simplifies to ^
Oh... I didn't understand the whole construct, then. Thanks! I guess "Possessive sub-pattern with non-greedy..., etc." can be stricken out from title. To be replaced with, start-of-string anchor and failure? Because,
Match fails -- it's irrelevant
But looks like it is. And, in parallel, comparing with look-ahead, which at 1st glance can be a simpler alternative (?):
say $-[1], ': ', $1 while 'olololo' =~ / (?= ( (.)(?-2)\g-1 | (.).\g-1 ) ) /gx; say '*'; say 'match' if 'olololo' =~ / ^ ( ( (.)(?-3)\g-1 | (.).\g-1 ) (?{ say $-[2], ': ', $2 }) ) (?#*F) /x;
Output:
0: olololo 1: lolol 2: ololo 3: lol 4: olo * 4: olo 3: lol 2: ololo 2: olo 1: lolol 0: olololo match
Look-ahead misses some PD's for obvious reasons. But match success in case of recursion leads to omission of 2 PD's, too. Why? Converting "comment" to "fail" i.e. (F*) gives all nine PD's, visited exactly once each (with some disruption to "visit in reverse" order):
4: olo 3: lol 2: ololo 2: olo 1: lolol 0: olololo 1: lol 0: ololo 0: olo
In reply to Re^2: Possessive sub-pattern with non-greedy content + recursion: WHY does this work??
by Anonymous Monk
in thread Possessive sub-pattern with non-greedy content + recursion: WHY does this work??
by Anonymous Monk
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |