How to replace a string in Groovy

I have a line like

C:\dev\deploy_test.log 

I want to use Groovy to convert a string to

 C:/dev/deploy_test.log 

I try to execute it with a command

 Change_1 = Log_file_1.replaceAll('\','/'); 

It does not convert this string

+7
groovy
source share
1 answer

You need to avoid backslash \ :

 println yourString.replace("\\", "/") 
+15
source share

All Articles