I would like to squeeze 'n' the number of slashes into 1, where n is not fixed.
For instance:
String path = "Report\\\\\\n";
Expected Result: "Report\\n"
I tried the following way
System.out.println(path.replaceAll("\\+", "\");
But he is typing "Report\\\n"
I can not reduce more.
All related questions / answers related to a fixed number of slashes.
Is there any general way I can compress all backslashes to one?
source
share