Don't ask to ask, just ask | |
PerlMonks |
Dominus on the non-greedy version of the ? quantifierby Aristotle (Chancellor) |
on Aug 06, 2006 at 21:10 UTC ( [id://565864]=perlquestion: print w/replies, xml ) | Need Help?? |
Aristotle has asked for the wisdom of the Perl Monks concerning the following question: So I was just looking at Dominus’ Regular Expression Mastery talk, since I hadn’t seen it before. I’ve been around the block enough times to know the subject matter cold, but of course understanding and mastery are separate issues and it’s always good to take another look – in complex subjects, other people will often bring up angles to look at some of their aspects that you never thought of before. Anyway, I was skimming the slides, but it didn’t look like I’d be taking home anything from this talk. Until I came to the absolute end, the very last bullet of the very last slide:
I’ve been staring at that example for 10 minutes and I really can’t see how it would ever match differently from the greedy version:
From what I can tell, since the entire pattern is anchored at both ends and the captures are nested, it must always match the exact same things, whether the quantifiers are greedy or not. Am I missing something? Makeshifts last the longest.
Back to
Seekers of Perl Wisdom
|
|