in reply to Re^2: Substitution backreference woes
in thread Substitution backreference woes

yeah sorry I wasn't able to test from Android, the problem is that the substitution part of s/// is supposed to be a literal. Otherwise you have to apply the /e eval modifiers.

my $string = 'Hello sailor'; my $regex = 'Hello (.*)'; # my $substitution = 'Goodbye \1'; $string =~ s/$regex/Goodbye $1/; print "string is now <$string> \n";

/usr/bin/perl -w /tmp/regex.pl string is now <Goodbye sailor>

Please note that \1 is somehow deprecated in the substitution part and will cause warnings.

Its only legitimate use is in the match part for backreference.

Cheers Rolf

PS: Je suis Charlie!