On Thu, 14 Dec 2000, Deven T. Corzine wrote:

> Here is a simple example: (tested with perl 5.005_03)
> 
>      $_ = "aaaabbbbccccddddeeee";
>      ($greedy) = /(b.*d)/;              # "bbbbccccdddd" (correct)
>      ($non_greedy) = /(b.*?d)/;         # "bbbbccccd" (should be "bccccd"!)

> Does anyone disagree with the premise, and believe that "bbbbccccd" is the
> CORRECT match for the non-greedy regexp above?

the quantifier applies to the .* portion. that part finds its shortest
possible match.  the regex engine, however, choose the first "b" it
encountered as it's start point.  this is unrelated to the behaviour of ?.
you don't like that it finds the earliest match, instead of, say, the
longest match or the shortest match, or even all the possible matches
(hmmm... module idea ;).

perhaps, however, Perl 6 wil allow you to easily use your own custom regex
engine and then you can make it do whatever you like. ;)

--
brian d foy                              <[EMAIL PROTECTED]>
Director of Technology, Smith Renaud, Inc.
875 Avenue of the Americas, 2510, New York, NY  10001
        V: (212) 239-8985


Reply via email to