javascript - Jquery- backslash character -
i having problem trying replace backslash character string:
var g = myreadstring; g = g.replace("\", "\\\\");
it giving error of unrecognized character.
how simple \
replaced 4 \\\\
?
i appreciate help, thanks. pandy
the \
begin of escape sequence. if mean write \
literally, need write \\
escape sequence , interpreted single \
. if want replace 1 \
4 \\\\
, need write this:
g.replace("\\", "\\\\\\\\")
but replace first occurrence of single \
. global replace need use regular expression global match modifier:
g.replace(/\\/g, "\\\\\\\\")
Comments
Post a Comment