I'm trying to replace backslashes with forward slashes in javascript with the replace function and regex but can't get it to work. Thought it would be the following but it doesn't work:
path.replace("/\\/g", "//")
If I had a path that looks like D:\Games\Scrolls\ what would the regex be to replace to D:/Games/Scrolls/?
Use the regex pattern without a string type
path.replace(/\\/g, "/")
This should do the trick
path=path.replace(/\\/g,"/");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With