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:47
Re: Perl 5's "non-greedy" matching can be TOO greedy!
Message ID:

On 15 Dec 2000, Randal L. Schwartz wrote:

> >>>>> "Deven" == Deven T Corzine <> writes:
> Deven> As for special-case rules, I believe that my proposed modification would
> Deven> REMOVE a special-case semantic rule, at the cost of added complexity at the
> Deven> implementation level.  (The cost decision of whether that added complexity
> Deven> is worthwhile is a separate consideration.)
> No, it would break a much higher overriding rule of "left most match
> wins".  That's at the top of the chart.  You're *adding* an exception
> to that.  Tell me how you can do that without breaking much existing
> code.

Can you give a concrete, real-life example of code that my proposed change
would actually break, not a contrived hypothetical case design to break?

Adding the requirement for "\@" in double-quoted strings broke a LOT of
Perl 4 code.  I doubt this would break much at all.

> Deven> And I'd really appreciate it if everyone would refrain from
> Deven> suggesting that I don't understand the behavior.  I understand
> Deven> it fine; I just don't agree with it.  In the language of the
> Deven> Supreme Court, "I respectfully dissent."  Just because I don't
> Deven> perfectly agree with the semantics that were chosen doesn't
> Deven> mean I don't understand them.
> You don't understand the motivation, apparently.  That's what I'm
> referencing.

I don't understand the motivation behind taking leftmost matching to such
extremes.  I understand the importance of leftmost matching in general;
this is a particular situation where I believe it's being taken a little
too far for the good of the whole.

However, some of the comments that have been made seem to imply that I'm
simply ignorant about regular expressions and I need to learn them better.

My questioning the behavior arises out of philosophy, not ignorance.

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