I have some string like
C:\dev\deploy_test.log I want by means of Groovy to convert string to
C:/dev/deploy_test.log I try to perform it with command
Change_1 = Log_file_1.replaceAll('\','/'); It doesn't convert this string
2 Answers
You need to escape the backslash \:
println yourString.replace("\\", "/") 2You could also use Groovy's slashy string, which helps reduce the clutter of Java's escape character \ requirements. In this case, you would use:
Change_1 = Log_file_1.replaceAll(/\/,'/');
Slashy strings also support interpolation, and can be multi-line. They're a great tool to add to your expertise.