Reputation: 131
Is it possible replace all backslash \\
to forward slash /
in Groovy?
String someString = rootDir
someString.replace("\\","////")
This doesn't seem to work.
Upvotes: 2
Views: 1792
Reputation: 23805
def someString = "a\\b\\c\\d/e/f/g/h"
println someString
println someString.replaceAll("\\\\", "/")
produces the output:
a\b\c\d/e/f/g/h
a/b/c/d/e/f/g/h
Note that replaceAll
does not modify the string in place, but returns a new modified string.
Upvotes: 3