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

[email protected] (Tom Christiansen) Fri, 15 Dec 2000 13:53:26 -0700
Newsgroups perl.perl6.language.regex
Message-ID <3079.976913606@chthon>
>Really?  I haven't taken a survey, but I did ask one co-worker for his
>first impression of what the regexp (from my example) would match.  Not
>being an experienced Perl programmer, but being familiar with regular
>expressions, he believed he understood the idea of non-greedy matching.
>His expectation?  That would match "bccccd", not "bbbbccccd".

I'm sure you invalidated the test results by giving the wrong set up.
Listen very closely:

    PERL DOES NOT HAVE GREEDY MATCHING.

Got that?  Neither does it have stingy matching.  Only the quantifiers
have such a property.  NOT THE MATCH ITSELF.    Wait, let me say it again:

    PERL DOES NOT HAVE GREEDY MATCHING.

There is no global greed, only local greed.  And greed is a misleading
term.

--tom