E
el_roachmeister
I am trying to perform a regex on a string that contains a backslash. I
need the backslash in the string but I want to somehow escape it in the
regex. Can this be done? I have posted the code below which outputs
"Not Matched".
#!/usr/bin/perl
use warnings;
use strict;
my $name = 'John \ 123'; # backslash in name causes problem
my $test = $name;
if ($name =~ /$test/) {print 'Matched';}
else { print 'Not Matched';}
need the backslash in the string but I want to somehow escape it in the
regex. Can this be done? I have posted the code below which outputs
"Not Matched".
#!/usr/bin/perl
use warnings;
use strict;
my $name = 'John \ 123'; # backslash in name causes problem
my $test = $name;
if ($name =~ /$test/) {print 'Matched';}
else { print 'Not Matched';}