in reply to Re^2: Substitution backreference woes
in thread Substitution backreference woes
Forgive me, but the working examples do not seem to cover the use of \1 (etc) in the replacement expression.It's covered in perlop
Unlike sed, we use the \<digit> form in only the left hand side. Anywhere else it's $<digit>.Perl warns about it, too:
$ perl -wE '$_ = "foo"; s/(foo)/bar \1/; say' \1 better written as $1 at -e line 1. bar foo
We're told that backreference patterns can be used in the substitution by specifying \1, \2 (etc), but it doesn't seem to work.Who told you that?
|
|---|