Hi friends,
Using following Javascript sysntax you can replace forward slashes (‘/’) with backward slashes (‘\’) :
var strReplace = “C:\Temp\Temp1\Temp2\text.jpeg“;
strReplace = strReplace.replace(new RegExp(/\\/g),”/”);
Regardes,
Vijay
Hi friends,
Using following Javascript sysntax you can replace forward slashes (‘/’) with backward slashes (‘\’) :
var strReplace = “C:\Temp\Temp1\Temp2\text.jpeg“;
strReplace = strReplace.replace(new RegExp(/\\/g),”/”);
Regardes,
Vijay
Posted in JavaScript
Javascript String Replace Path
By: blueprints on September 12, 2008
at 5:05 am
Thanks a lot for the valuable solutions.
By: Megharaja on November 3, 2008
at 10:05 am
Nice Code, Thanks a lot
By: Hussain on June 30, 2009
at 2:52 pm
Hi, how would it be shifted, I mean, Replace backward slashes ‘\’ with forward slashes ‘/’.
By: Mario on September 2, 2009
at 4:03 pm
That is right, your description is wrong, you are replacing \ for /….
what about the opposite one, how could it be done?
By: Trueman on September 9, 2009
at 3:02 pm
Use this to replace “/” with “\”. The code may not look right depending on your code editor, but it’ll work.
By: Lou on September 15, 2009
at 8:22 pm
oops, forgot to add the code:
strReplace = strReplace.replace(/\//g, “\\”);
By: Lou on September 15, 2009
at 8:22 pm
Here is the code you guys are asking for:
strReplace = strReplace.replace(/\//g, “\\”);
By: Lou on September 16, 2009
at 4:18 pm