Replace string that contains \

I’m looking to replace a string such as C:\Users\username\Desktop with a different path, i.e. C:\Users\username\New Folder. UIPath doesn’t seem to like this because of the , the escape character. The error message I’m getting is, “unrecognized escape character”

I believe the regex thing I"m looking for is @, in python you can type r in front of the string. Anything similar in UIPath?

Hi
Welcome to uipath community
Yah we can use @in front of string that has \ kind of special characters to take that as a string literal and @ is usually used in C#

But here in your scenario to replace the term as you have mentioned we don’t need this @ to be used
We can mention like this
If str_path = “C:\Users\username\Desktop”
Then
str_output = Split(str_path,”/“)(0)+”/“ +Split(str_path,”/“)(1)+”/“+Split(str_path,”/“)(2)+”/“+”your new folder name”

Or
We can directly use CREATE DIRECTORY activity if we are trying to create a new folder

Or
We can use MOVE file activity where we can move one file from one filepath to another file path

Hope this would help you
Cheers @Chris_Thomas