laziness, impatience, and hubris | |
PerlMonks |
Re^3: Regex error when [] occurs in file.. ($1 vs. \1)by almut (Canon) |
on Mar 03, 2008 at 16:31 UTC ( [id://671674]=note: print w/replies, xml ) | Need Help?? |
I think you meant
in which case any special characters in the content of the backreference \1 would not be treated special. IOW, "[0-9]blah[0-9]" would match, but not "[0-9]blah6":
prints
while, if you replace \1 with $1 in the above regex, it prints
This is because $1 isn't defined here, thus the regex effectively becomes /(\[0-9\])blah/... Update: added demo code.
In Section
Seekers of Perl Wisdom
|
|