http://qs321.pair.com?node_id=719287


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