Replace Single Backslash with Double Backslash
I have a need to replace single backslashes with double backslashes. I know that the replace method of the string object can be used, however I'm not able to figure out the correct combination given that the backslash serves as an escape character.
Needs to become
you need to use "\\" to display one, so for "\\" you need to use "\\\\"
I was doubling up on them, but not getting the results that I needed.
Its now a moot point as I ran into some other issues that required a complete overall eliminating the need entirely.
It seems to work better with a regular expression
var t="\\\\[string]\\[string]\\[string]";alert("Before "+t);
var u=t.replace(/\\/g,"\\\\");alert("After "+u);
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)