Re: Special characters and variables in search and replace expressions of regexps

2008-12-14 Thread John W. Krahn
Alexei A. Frounze wrote: Here's a sample program to show the problems I'm having with regexps: my $s = "a\tb"; $s contains a three character string, the 'a' character, the TAB character and the 'b' character. my $m1 = "\t"; $m1 contains a single TAB character. my $m2 = "\\t"; # both "\t

Special characters and variables in search and replace expressions of regexps

2008-12-14 Thread Alexei A. Frounze
Here's a sample program to show the problems I'm having with regexps: my $s = "a\tb"; my $m1 = "\t"; my $m2 = "\\t"; # both "\t" and "\\t" are treated specially my $r1 = "\t"; my $r2 = "\\t"; my $s1 = $s; my $s2 = $s; $s1 =~ s/$m1/$r1/; $s2 =~ s/$m1/$r2/; print "\"$s\" =~ s/$m1/$r1/ -> \"$s1\"\n"