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

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

Thread Previous | Thread Next
From:
Tom Christiansen
Date:
December 15, 2000 12:53
Subject:
Re: Perl 5's "non-greedy" matching can be TOO greedy!
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

Thread Previous | Thread Next


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