On Jun 13, Josh said:
>Hi all,
> I'm reading Mastering Regular Expressions and it discusses a
>non-greedy version of star. can someone explain how to write this
>non-greedy version of star. (i.e. how does it differ than just *)
Thanks to Peter for plugging my modules... you might also want to take a
look at "Regular Expressions in Perl", which can be found at
http://www.pobox.com/~japhy/docs/book.html
I talk about greediness vs. non-greediness (or laziness) in chapter 6, I
believe.
The main difference is that * matches as much as it can, and then backs
off slowly until a match is complete, whereas *? matches as little as it
can, and inches forward slowly until a match is complete.
Think of it as searching through a book for something. Sometimes you're
greedy and start at the end and flip backwards. Sometimes you're lazy and
go forwards.
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk? http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
** Manning Publications, Co, is publishing my Perl Regex book **