I need to replace this path: C:\test1\test2
into this:
C:/test1/test2
I am using jquery but it doesn't seem to work
var path = "C:\test1\test2";
var path2 = path.replace("\", "//");
How should it be done?
I need to replace this path: C:\test1\test2
into this:
C:/test1/test2
I am using jquery but it doesn't seem to work
var path = "C:\test1\test2";
var path2 = path.replace("\", "//");
How should it be done?
You have to escape to backslashes.
var path = "C:\\test1\\test2";
var path2 = path.replace(/\\/g, "/");
console.log(path2);
Your original string is in the wrong format, as '\t' inside it is for a tab symbol. Please change it (may be from the server side) to this:
var path = "C:\\test1\\test2";
so your code could change to this:
var path = "C:\\test1\\test2";
var path2 = path.replace(/\\/g, '/');