Hello AnomalousMonk, and thanks for the writeup.
Is your Supplemental question meant rhetorically? Because I, for one, would really like to know the answer! Consider the following:
19:40 >perl -wE "my $s = 'abCdefC'; while ($s =~ / (f)*? C /gx) { say +qq[match: $1, pos = ], pos $s; }" Use of uninitialized value $1 in concatenation (.) or string at -e lin +e 1. match: , pos = 3 match: f, pos = 7 19:41 >
In this case the regex engine does not say: “Well, matching 1 f is better than matching none, so I’ll match the fC sequence first.” On the contrary, it first matches the C preceded by zero fs, as one might reasonably expect from the quantifier, *?, which says, “match this zero or more times in a non-greedy way.” I actually don’t understand how this can ever, logically, match with more than zero, since zero is possible and less greedy than 1??
But back to the OP, how does $dna =~ / (\w\w\w)*? TGA /gx differ logically from $s =~ / (f)*? C /gx? I can’t see a fundamental distinction here, yet there must be one because the former finds a non-empty match for (\w\w\w) before it looks for an empty one!
Thanks,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re^7: Understanding a portion of perlretut
by Athanasius
in thread Understanding a portion on the Perlretut
by BlueStarry
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |