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

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

Deven T. Corzine
December 15, 2000 11:41
Re: Perl 5's "non-greedy" matching can be TOO greedy!
Message ID:

On Thu, 14 Dec 2000, Jarkko Hietaniemi wrote:

> On Thu, Dec 14, 2000 at 04:19:15PM -0700, Nathan Torkington wrote:
> > Deven T. Corzine writes:
> > > I haven't even SEEN an example where the current behavior is actually
> > > preferable than my proposed behavior, have you?  (And I'd expect at least a
> > > FEW, though I suspect there are probably more counterexamples.)
> > 
> > I think the biggest problem with your idea is that it requires the
> > engine to keep looking even after it finds a match, to see if there's
> > another shorter match.  This would make *every* match much much
> > slower, potentially heatdeathoftheuniverse slower.

I suppose if my proposal is useful, but still considered a "special-case",
having it as an option might be an approach to take, if it's worth having
as an alternative.

> Couldn't the be an option (a modifier) to do this?  Then if someone
> asks to wait until all the electrons spin down, so be it...

> > I like the current semantics because it's very easy to visualize the
> > engine acting on your instructions and stopping as soon as it finds a
> > match.  I am a programmer, and I prefer programs to descriptions.

The functioning of the NFA is a means to an end.  The end is the high-level
concept of "pattern matching", for which the semantics are perhaps a little
different.  (Or perhaps not; we're not in agreement on that point.)

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