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

[email protected] ("Deven T. Corzine") Fri, 15 Dec 2000 16:14:16 -0500 (EST)
Newsgroups perl.perl6.language.regex
Message-ID <[email protected]>
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