develooper Front page | perl.perl6.language.regex | Postings from December 2000

Re: Perl 5's "non-greedy" matching can be TOO greedy!

From:
Deven T. Corzine
Date:
December 15, 2000 13:14
Subject:
Re: Perl 5's "non-greedy" matching can be TOO greedy!
Message ID:
Pine.LNX.4.10.10012151613180.31056-100000@escher.ties.org

On Fri, 15 Dec 2000, Tom Christiansen wrote:

> >You can't explain why "bbbbccccd" matches without making reference to the
> >absolute priority of the leftmost rule.  "bccccd" would still make sense
> >(locally) without reference to that rule.
> 
> Nope.  Nope, nope, and nope.
> 
> Th8is /bbbbccccd/ thing, which is completely unrealistic and
> non-real-worldly, says:
> 
> 	find a 
>     b
> 	such that this is immediately followed by 
>     b
> 	such that this is immediately followed by 
>     b
> 	such that this is immediately followed by 
>     b
> 	such that this is immediately followed by 
>     c
> 	such that this is immediately followed by 
>     c
> 	such that this is immediately followed by 
>     c
> 	such that this is immediately followed by 
>     c
> 	such that this is immediately followed by 
>     d
> 
> If you think that people for "find a b" to suddently mean 
> something stochastic, you know different people than I do.

That would be a strange regexp, but I never suggested it.  I suggested the
regexp /b.*?d/ and pointed out that I believe "bccccd" is a more intuitive
match than "bbbbccccd".  That was the matching text, not the regexp, sorry
if I didn't make that clear.

Deven




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About