Reputation: 2560
i have a string like the following
var string1 = " folder\\subfolder1\\subfolder2 "
and i want to replace the "\" with "/" with string1.replace in order to be
var string2 = "folder/subfolder1/subfolder2"
I tried
var rep = path.replace("\\", "/");
but is not working. Any help ?
Upvotes: 0
Views: 611
Reputation: 175776
You need to do it globally, for example with a regexp literal & the g
flag;
var rep = path.replace(/\\/g, "/");
Upvotes: 3