From:

Date:

May 31, 2007 03:02Subject:

did I get greedy quantifiers wrong ?Message ID:

8a31202a0705310302y1822ca58y9507522e3b9a262d@mail.gmail.comI seem to be having some conceptual problem with greedy quantifiers .. My understanding is that it matches as much as follows while still allowing rest of the regex to match. But look at the following example : $str = mississippi; $str =~ m/m(.*i)(.*pi)/; print "one is $1 \n"; print "two is $2 \n"; $str = mississippi; $str =~ m/m(.*i?)(.*pi)/; print "one is $1 \n"; print "two is $2 \n"; In the first code snippet, I expected first regex (.*i) to match till ississip and leave pi for (.*pi) regex. But what I get as the output of this script is : one is ississi two is ppi one is ississip two is pi Why is that perl is leaving ppi to second regex while it can continue till first p in ppi and can still get the second regex to get a match ? Thanks, SharanThread Next

**did I get greedy quantifiers wrong ?**by Sharan Basappa- Re: did I get greedy quantifiers wrong ? by nobull67@gmail.com
- Re: did I get greedy quantifiers wrong ? by Sharan Basappa
- Re: did I get greedy quantifiers wrong ? by jeevs
- Re: did I get greedy quantifiers wrong ? by Paul Lalli
- Re: did I get greedy quantifiers wrong ? by Sharan Basappa
- Re: did I get greedy quantifiers wrong ? by Paul Lalli
- Re: did I get greedy quantifiers wrong ? by Sharan Basappa
- Re: did I get greedy quantifiers wrong ? by yitzle
- Re: did I get greedy quantifiers wrong ? by Chas Owens
- Re: did I get greedy quantifiers wrong ? by Sharan Basappa
- Re: did I get greedy quantifiers wrong ? by Chas Owens
- Re: did I get greedy quantifiers wrong ? by Chas Owens

nntp.perl.org: Perl Programming lists via nntp and http.

Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About