regular expression match question
- From: pyan@xxxxxxxxxx (Pine Yan)
- Date: Fri, 29 Jul 2005 11:04:52 -0700
A script like this:
line1: $string3 = "bacdeabcdefghijklabcdeabcdefghijkl";
line2: $string4 = "xxyyzzbatttvv";
line3: print "\$1 = $1 \@{$-[0],$+[0]}, \$& = $&\n" if($string3
=~ /(a|b)*/);
line4: print "\$1 = $1 \@{$-[0],$+[0]}, \$& = $&\n" if($string4
=~ //);
Run and gett result:
$1 = a @{0,2}, $& = ba
$1 = @{0,0}, $& =
If I change the code of line3 to:
print "\$1 = $1 \@{$-[0],$+[0]}, \$& = $&\n" if($string3 =~
/(a|b)+/);
and keep everything else the same, I will get:
$1 = a @{0,2}, $& = ba
$1 = a @{6,8}, $& = ba
This result doesn't look very promising to me. The first matching
results keeps the same
between * and +, while the second who is supposed to inherit the
pervious match shows
different result.
The version I'm using is 5.6.1. Can anyone tell why is this? A bug? Or
some tricky I can't
figure out? Does this work differently in latest release?
Thanks.
Sincerely
Pine
- Follow-Ups:
- Re: regular expression match question
- From: Jeff 'japhy' Pinyan
- Re: regular expression match question
- Prev by Date: Remembering Positions in Array after processing the element
- Next by Date: Re: IF statements and modules - do they mix?
- Previous by thread: Remembering Positions in Array after processing the element
- Next by thread: Re: regular expression match question
- Index(es):
Relevant Pages
|