Bilow Yuriy Bilow Yuriy - 2 months ago 6
Groovy Question

How to replace string in Groovy

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

Answer

You need to escape the backslash \:

println yourString.replace("\\", "/")
Comments