Author:
erics, February 11th, 2021
## to add a single backslash in front of whatever char was matched
|
my $password = q#abc'A1r%Fgt&jh[-#; $password =~ s/(['])/\\$1/g; print qq#'$password'\n#; 'abc\'A1r%Fgt&jh[-' |
## to double whatever char was matched
|
my $password = q#abc'A1r%Fgt&jh[-#; $password =~ s/(['])/$1$1/g; print qq#'$password'\n#; 'abc''A1r%Fgt&jh[-' |
## to convert ‘ to ‘\” for shell execution
|
my $password = q#abc'A1r%Fgt&jh[-#; $passwordShell =~ s/(['])/$1\\$1$1/g; print qq#'$password'\n#; 'abc'\''A1r%Fgt&jh[-' |
Categories: How-To's, Technology Tags: Backslash, Characters, double, double quotes, Escape, howto, perl, quote, quotes, Replace, Single, single quotes, Speci, Special, Special character, Substitute, tips
| No comments