I have the following problem:
I have a script that executes an AJAX request to a server, the server returns C:\\backup\\
in the preview. However, the r
Best is to use regex to replace all occurrences:
C:\\backup\\".replace(/\/\//g, "/")
this returns: C:\backup\
OR
use split()
"C:\\backup\\".split();
both produces your desired result
C:\backup\
console.log("using \"C:\\backup\\\".replace(/\/\//g, \"/\")")
console.log("C:\\backup\\".replace(/\/\//g, "/"));
console.log("Using \"C:\\backup\\\".split()");
console.log("C:\\backup\\".split());
This should do it: "C:\\backup\\".replace(/\\\\/g, '\\')
In the regular expression, a single \
must be escaped to \\
, and in the replacement \
also.