in reply to Help with regex using variables
$find="C:\\Dir1\\Dir2\\Dir3"; $replace=''; $var = "C:\\Dir1\\Dir2\\Dir3\\KeepMe"; $var =~ s/$find/$replace/eeg; print "\$var: $var\n";
The first line interpolates the double quoted string, converting "\\" to '\'.
The fourth line also interpolates the string.
Try using either $find='C:\\Dir1\\Dir2\\Dir3'; or better yet use $find = qr/C:\\Dir1\\Dir2\\Dir3/;.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Help with regex using variables
by haukex (Archbishop) on May 16, 2023 at 07:24 UTC |