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

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

From:
Tom Christiansen
Date:
December 15, 2000 13:00
Subject:
Re: Perl 5's "non-greedy" matching can be TOO greedy!
Message ID:
9824.976913992@chthon
>On Fri, 15 Dec 2000, Tom Christiansen wrote:

>> >As for special-case rules, I believe that my proposed modification would
>> >REMOVE a special-case semantic rule, at the cost of added complexity at the
>> >implementation level.  
>> 
>> What is this alleged "special-case rule" you are talking about?
>> There is no such thing.  None.  When you write /pat/, it means to
>> find the first such pattern.  There is no special case here.

>The special case is "as long as it has the earliest starting position".

>There may be many, many possible matches for a regexp in a given string,
>especially with an expression as inclusive as ".*".  

You want to change things from "find a match", which has the obviously
deterministic semantics of finding the first match, and alter that
to mean "find all possible matches; now, amongst those...".  This
is much more complicated, at many levels.

You have yet to address my long mail to you.

You have yet to read MRE.

>So, you have to apply some disambiguating rules to identify which matches
>are "interesting" enough to be worth paying attention to.  

There is no ambiguity.  Short-circuiting it not ambiguity.  Stopping when
you have an answer is not ambiguity.  You are mistaken.

--tom



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