in reply to Re: Regex, capturing variables vs. speed
in thread Regex, capturing variables vs. speed
andperl -Mre=debug -le'"lahblahblahblah" =~ /(.?lah)$1{2}/'
perl -Mre=debug -le'"lahblahblahblah" =~ /(.?lah)\1{2}/'
The first one matches on "lahblahblah", and the second one matches on "blahblahblah". Why do you suppose that is?
The debugging engine appears to see the $1 as an almost literal copy of the regexp in the brackets. Whereas the \1 seems to be looking for whatever was matched by the regexp in the brackets..
Update: Thanks to Aristotle for pointing out the error in the $1 interpretation.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Regex, capturing variables vs. speed
by Aristotle (Chancellor) on Nov 02, 2005 at 04:39 UTC |