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

2000-12-14 Thread Deven T. Corzine
Oh, my. I fear I may have ruffled some feathers here. I apologize; I was hoping to spark a debate, not a flame war. Could we all please take a step back and cool off for a bit, and not let this get personal? I'm afraid it may seem like I'm ranting about Perl 5's regular expressions, when I onl

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

2000-12-14 Thread Jeff Pinyan
On Dec 14, Randal L. Schwartz said: >Deven> I haven't even SEEN an example where the current behavior is >Deven> actually preferable than my proposed behavior, have you? (And >Deven> I'd expect at least a FEW, though I suspect there are probably >Deven> more counterexamples.) > >If I want the le

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

2000-12-14 Thread Nathan Wiger
>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. > >Here is a simple example: (tested with perl 5.005_03) > > $_ = ""; > ($greedy) = /(b.*d)/;

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

2000-12-14 Thread Randal L. Schwartz
> "Deven" == Deven T Corzine <[EMAIL PROTECTED]> writes: Deven> I haven't even SEEN an example where the current behavior is Deven> actually preferable than my proposed behavior, have you? (And Deven> I'd expect at least a FEW, though I suspect there are probably Deven> more counterexamples.

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

2000-12-14 Thread Randal L. Schwartz
> "Deven" == Deven T Corzine <[EMAIL PROTECTED]> writes: Deven> I'm not pushing for this to be fixed in Perl 5; it's been out Deven> there long enough, and there's no point worrying about it in Deven> that version. But that doesn't mean that the same design flaw Deven> should be kept in Perl

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

2000-12-14 Thread Tom Christiansen
>No question that's how it's been implemented. But WHY would anyone want >such behavior? When is it beneficial? It is beneficial because this is how it's always been, because it is faster, because it is more expressive, because it is more powerful, because it is more intuitive, and because it i

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

2000-12-14 Thread Nathan Torkington
Jarkko Hietaniemi writes: > 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... Only if we can get MjD's wordy regex modifiers: /a.*?b/{heatdeath} Nat :-)

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

2000-12-14 Thread Jarkko Hietaniemi
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

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

2000-12-14 Thread Nathan Torkington
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 re

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

2000-12-14 Thread Deven T. Corzine
On Thu, 14 Dec 2000, Jeff Pinyan wrote: > On Dec 14, Deven T. Corzine said: > > >> You're asking for something like > >> > >> /(? >> > >> which is an "optimization" you'll have to incorporate on your own. > > > >Thanks for the example. Unfortunately, your attempted workaround doesn't > >ev

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

2000-12-14 Thread Jeff Pinyan
On Dec 14, Deven T. Corzine said: >> You're asking for something like >> >> /(?> >> which is an "optimization" you'll have to incorporate on your own. > >Thanks for the example. Unfortunately, your attempted workaround doesn't >even work for the example string; the "a" preceding "d"

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

2000-12-14 Thread Deven T. Corzine
On Thu, 14 Dec 2000, Jeff Pinyan wrote: > On Dec 14, Deven T. Corzine said: > > >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. > > That's because "greediness" is just a m

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

2000-12-14 Thread Deven T. Corzine
On Thu, 14 Dec 2000, Tom Christiansen wrote: > >Does anyone disagree with the premise, and believe that "d" is the > >CORRECT match for the non-greedy regexp above? > > Yes. The Camel's regex chapter reads: > > You might say that eagerness holds priority over greed (or thrift). N

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

2000-12-14 Thread Jeff Pinyan
On Dec 14, Deven T. Corzine said: >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. That's because "greediness" is just a measure of crawl vs. backtrack. The regex /a.*b/ will ma

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

2000-12-14 Thread Tom Christiansen
>Does anyone disagree with the premise, and believe that "d" is the >CORRECT match for the non-greedy regexp above? Yes. The Camel's regex chapter reads: You might say that eagerness holds priority over greed (or thrift). >For what it's worth, here's a quote from a Perl 5.005_03 "p

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

2000-12-14 Thread Deven T. Corzine
Non-greedy matching is a very valuable Perl 5 regular expression feature that simplifies many regular expressions. However, early on I discovered what seems to be a failure of the mechanism -- matches were MORE greedy than necessary. I'm not sure if other people noticed this, or just failed to c