in reply to How to substitute a string containing "\" with same string in quotes.
Hi
Please note that in your example coding the '$sting' and '$substing' are misspelled in some occurances, to avoid this use 'use strict;'
You can escape those slashes in the matching string by using '\Q and \E' like
use strict; my $string = "this is my sting with \ and /slashes. put substing in qu +otes"; my $substring = "with \ and /slashes"; $string =~ s/\Q$substring\E/\"$substring\"/gi; print $string;
Punitha
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: How to substitute a string containing "\" with same string in quotes.
by Rapunzel (Novice) on Oct 24, 2008 at 08:54 UTC | |
by ikegami (Patriarch) on Oct 24, 2008 at 09:08 UTC | |
by Punitha (Priest) on Oct 24, 2008 at 09:06 UTC |
In Section
Seekers of Perl Wisdom