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


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

Try this:


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


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.