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:
James Mastros
Date:
December 15, 2000 00:13
Subject:
Re: Perl 5's "non-greedy" matching can be TOO greedy!
Message ID:
20001214181842.B3476@lilith.belledonna.mine.nu
On Thu, Dec 14, 2000 at 04:10:12PM -0500, Deven T. Corzine wrote:
> The crux of the problem is that non-greedy qualifiers don't affect the
> "earliest match" behavior, which makes the matches more greedy than they
> really ought to be.
Right.  We've got a terminoligy issue.  There's two axes here:

Greed: Greedy by default.  Will try to match as many chars after its
starting point as possible.  Non-greedy will try to match as few chars after
its starting point as possible, and is denoted by putting a '?' after a
quantifer.

Lazyness: Eager by default.  An eager assertation will try to match as early
as possible.  It isn't possible to use lazy assertations at present.  (Not
simply, anyway.  It's probably possible to combine other (?) features to get
the same effect.)

You seem to want the choice between greedy, eager assertations, and
non-greedy, lazy assertations.  If you came up with a good way to specify
along both axes, I think we'd have a winner.

      -=- James Mastros
-- 
midendian: She never sleeps.
mousetrout: But I do.  I just regret it after I wake up.

AIM: theorbtwo homepage: http://www.rtweb.net/theorb/
ICBM: 40:04:15.100 N, 76:18:53.165 W

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