"Deven T. Corzine" <[EMAIL PROTECTED]> writes:
>I've yet to see a concrete example of where the current behavior is
>helpful,
What about matching C comments?
($first_comment) = $code =~ m!(/\*.*?\*/)!s;
# (ignore issues with quoted strings in $code
Works correctly under the current behavior. It would break under you
proposal (if I understand your proposal correctly).
More generally, it seems to me that you're hung up on the description
of "*?" as "shortest possible match". That's an ambiguous
simplification of what "*?" means. It might better be described as
"match until you find a match for the rest of the regex" ('d' in your
example). If oversimplifications in the documentation led you to
believe that "*?" meant something it was never intended to mean, then
perhaps the documentation should be clarified. But the meaning of
"*?" should not be changed.
Final point: In your example, /b[^bd]*d/ does what you want, and is
arguably easier to understand. Can you think of any examples where
it's not this easy to get the behavior you desire?
- Re: Perl 5's "non-greedy" matching can be TO... Deven T. Corzine
- Re: Perl 5's "non-greedy" matching can ... Jeff Pinyan
- Re: Perl 5's "non-greedy" matching ... Deven T. Corzine
- Re: Perl 5's "non-greedy" match... Nathan Torkington
- Re: Perl 5's "non-greedy" m... Jarkko Hietaniemi
- Re: Perl 5's "non-greedy&qu... Nathan Torkington
- Re: Perl 5's "non-greedy&qu... Deven T. Corzine
- Re: Perl 5's "non-greedy" m... Deven T. Corzine
- Re: Perl 5's "non-greedy&qu... Jonathan Scott Duff
- Re: Perl 5's "non-greedy&qu... Deven T. Corzine
- Re: Perl 5's "non-greedy&qu... Kevin Walker
- Re: Perl 5's "non-greedy&qu... Jarkko Hietaniemi
- Re: Perl 5's "non-greedy&qu... Tom Christiansen
- Re: Perl 5's "non-greedy&qu... Kevin Walker
- Re: Perl 5's "non-greedy&qu... Bart Lateur
- Re: Perl 5's "non-greedy&qu... Deven T. Corzine
- Re: Perl 5's "non-greedy&qu... Tom Christiansen
- Re: Perl 5's "non-greedy&qu... Deven T. Corzine
- Re: Perl 5's "non-greedy" match... Randal L. Schwartz
- Re: Perl 5's "non-greedy" m... Jeff Pinyan
- Re: Perl 5's "non-greedy&qu... Deven T. Corzine
