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

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -