K
kiranmn
hi,
I want all doublequote in a string to be prefixed with '\'. I want
to achive this with a regular expression and this regular expression
will be in a loop, so for the same input if this same RE runs multiple
times, it will add multiple '\` before doublequote, to avoid that i
am checking for " NOT A BACKSLASH" in following RE.
Following RE works for me, but it fails for two consecutive
doublequotes.
Why RE is failing to replace second double quote, even with /g ?
regards,
kiran
------------------------------------------
Expect output
input is abc "" c " de
output is abc \"\" c \" de
------------------------------------------
current output
input is abc "" c " de
output is abc \"" c \" de
=========================
$input='abc "" c " de';
print "input is $input\n";;
$input=~ s/([^\\x])"/$1\\"/g;
print "output is $input\n";;
============================
I want all doublequote in a string to be prefixed with '\'. I want
to achive this with a regular expression and this regular expression
will be in a loop, so for the same input if this same RE runs multiple
times, it will add multiple '\` before doublequote, to avoid that i
am checking for " NOT A BACKSLASH" in following RE.
Following RE works for me, but it fails for two consecutive
doublequotes.
Why RE is failing to replace second double quote, even with /g ?
regards,
kiran
------------------------------------------
Expect output
input is abc "" c " de
output is abc \"\" c \" de
------------------------------------------
current output
input is abc "" c " de
output is abc \"" c \" de
=========================
$input='abc "" c " de';
print "input is $input\n";;
$input=~ s/([^\\x])"/$1\\"/g;
print "output is $input\n";;
============================