0

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
1

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

1

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.