Reputation: 583
How would you replace /
with \
in Groovy? So that
"//10.1.1.1/temp/test"
becomes "\\10.1.1.1\temp\test"
.
"//10.1.1.1/temp/test".replaceAll(/'\\/'/,'\\')
<-- ? doesn't work
Does anyone have an idea?
Thanks for any answer.
Upvotes: 4
Views: 12304
Reputation: 1219
Please check this
String path = 'D:/folder1/folder2/yourfile'
String result = path.replaceAll( "/","\\");
Finally you get result like
'D:\folder1\folder2\yourfile'
Upvotes: -1
Reputation: 6206
Look at this "//10.1.1.1/temp/test".replaceAll("/","\\\\")
. "\\\\"
makes a single backslash.
Upvotes: 12