# The string these literals produce don't contains any "\". my $string = "my string with \ and / slashes."; my $substring = "with \ and / slashes"; print("$string\n"); print("$substring\n"); print("\n"); # This is what the literals should be. $string = "my string with \\ and / slashes."; $substring = "with \\ and / slashes"; print("$string\n"); print("$substring\n"); print("\n"); # It works. $string =~ s/\Q$substring\E/\"$substring\"/gi; print("$string\n");
my string with and / slashes. with and / slashes my string with \ and / slashes. with \ and / slashes my string "with \ and / slashes".
In reply to Re^3: How to substitute a string containing "\" with same string in quotes.
by ikegami
in thread How to substitute a string containing "\" with same string in quotes.
by Rapunzel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |