Question

I tried using

string.replace("\","\");

But this doesn't work and gives me a compilation error

Syntax error on tokens, delete these tokens
Was it helpful?

Solution

Use like bellow, You need escape Special characters

string.replace("\\","\");

OTHER TIPS

escape the special characters.

string.replace("\\","\");
String p = ...;
p.replaceAll("\\\\", "\");
System.out.println(p);

use this code to replace and getting output in console..

Thanks..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top