Groovy: Replace / in Path with \

Booyeoo picture Booyeoo · Aug 3, 2011 · Viewed 10.3k times · Source

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.

Answer

emstol picture emstol · Aug 3, 2011

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