Search code examples
groovyescapingbackslashslash

Groovy: Replace / in Path with \


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.


Solution

  • Look at this "//10.1.1.1/temp/test".replaceAll("/","\\\\"). "\\\\" makes a single backslash.