如何在 Groovy 中使用 replaceAll
方法,将 /
替换为 \
?使得 "//10.1.1.1/temp/test"
变成 "\\10.1.1.1\temp\test"
。
"//10.1.1.1/temp/test".replaceAll(/'\\/'/,'\\')
<-- ? 这种方式不起作用。
有没有任何想法呢?
感谢任何回答。
看看这个 "//10.1.1.1/temp/test".replaceAll("/","\\\\")
。 "\\\\"
代表一个反斜杠。
String path = 'D:/folder1/folder2/yourfile'
String result = path.replaceAll( "/","\\");
'D:\folder1\folder2\yourfile'
println it.toString().replaceAll("\\\\","/") }
- Booyeoo