>
>The regex /[ab]*/ on the string "bad" matches 'ba' because regexes are
>greedy by default. They want to match as MUCH as they can.
>
>BUT regexes also try to find the earliest match in the string. This is
>why /[ab]*/ on the string "cab" matches ''. Because the engine found a
>successful match of 0 a's or b's at the beginning of the string.
>
I think I've understood what you mean here.
So next question, :)
Why these two commands give different result:
line3: print "\$1 = $1 [EMAIL PROTECTED],$+[0]}, \$& = $&\n"
if($string3
=~ /(a|b)*/);
line4: print "\$1 = $1 [EMAIL PROTECTED],$+[0]}, \$& = $&\n"
if($string4
=~ //);
result:
$1 = a @{0,2}, $& = ba
$1 = @{0,0}, $& =
Thanks!
Sincerely
Pine
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been overpaid?
http://www.perlmonks.org/ % -- Meister Eckhart
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>