Remove duplicate backslashes from URL

How can I remove duplicate backslashes from an URL?

C:\\Users\\User\\Desktop\\Document.xlsx

Should be

C:\Users\User\Desktop\Document.xlsx

I’m trying this, but since i just started trying to learn Regex expressions it clearly doesn’t work.

System.Text.RegularExpressions.Regex.Replace(Transaction, /([^:]/)/+/g)

1 Like

@LarsFeilberg

Welcome to the UIpath Community.

Try this:

String Str = “C:\Users\User\Desktop\Document.xlsx”

   Str.Replace("\\","\")
1 Like

Thanks alot, lakshman!

Oh, I see. That was a quite more convenient work-around I inted to use, instead of having to use Regex. Sometimes the more complex a problem seems, the more elegantly it can be solved :wink:

Cheers!

3 Likes

If you are still interested in regex.

New Regex("\\{2,}").Replace(Transaction, "\")

3 Likes