
Laurent_R
Veteran
/ Moderator
Oct 10, 2012, 4:49 AM
Post #2 of 2
(12917 views)
|
Re: [rajkumar] Perl Regex: not processing back references correctly
[In reply to]
|
Can't Post
|
|
Hi, I see no reason why ^(a*).*\1$ should fail to match aaabba. And I confirm that it DOES indeed match it. The regex engine first tries "aaa", but fails on the back reference. It then backtracks and tries "aa", and fails again. It backtracks again and tries "a", and then succeeds. Example on the command line:
perl -e '$c = "aaabba"; print "matched \"$1\"\n" if $c =~ /^(a*).*\1$/;' matched "a"
|