I have the input string "textfile\foldername\text.txt"
Now i need to convert given string to:

textfile/foldername/text.txt

I went through string.replace(oldchar, newchar) methods, but i actually couldnt remove the " and \ characters from the string. Need help

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by stultuske

Try this:

//...

string = string.replace('\\', '/'); // replace \ with /
string = string.replace('\"', ' '); // replace " with space
string = string.trim(); // remove leading and trailing spaces

//...

Edited by m4ster_r0shi: n/a

it would also be good practice to try and understand why you need escape characters there, and why you can't just replace the \ and " chars.