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
James Mastros
December 15, 2000 00:13
Re: Perl 5's "non-greedy" matching can be TOO greedy!
Message ID:
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

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:
ICBM: 40:04:15.100 N, 76:18:53.165 W

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About