Adding space in a string

Dear all,
I have a string (e.g String name = “JeffLeung”) and I would like to split it and adding space like “Jeff Leung” according to the uppercase letter. How can I do it in Uipath?

Please use the below expression in Assign Activity -

res = Regex.Replace(name, "(\p{Lu})", " $1").TrimStart

1 Like

Thank you for your reply. But I got a problem of using regex in Assign Activity, the error message is : ‘Regex’ is not declared.

Please add a namespace System.Text.RegularExpressions in your workflow.

You will find the namespace section, next to arguments panel.

1 Like

Thanks a lot!!:blush:

1 Like

I have question in following that expression what is the use of Lu
my input both are in lowercase letter means how to make space between to character (ex:tomchen)
then else my input in combination of both digit and string means how to make the space(ex:001tom)
please reply my queries as soon as possible

\p{Lu} will match an uppercase letter that has a lowercase variant.
'\d' will match a digit.

If both are lowercase letters then we can’t use any regex expression. The input must contain some pattern in order to work with regex expressions.

Karthik Byggari

1 Like


1 Like

I have a string - 246182373246849376246894309.
I need to split it in a group of 9 digits i,.e it should start with 246
Expected output - 246182373 246849376 246894309.

Is the string size fixed or will vary?

@KarthikByggari it varies

try this StringVar.Substring(0,9) + " “+StringVar.Substring(9,9) +” "+ StringVar.Substring(18,9)

1 Like


Or something like this

    Dim blah As String = "FirstNameLastName"
    Dim mc As MatchCollection = Regex.Matches(blah, "[A-Z][a-z]*")

    For Each m As Regex.Match In mc

Tested and working fine. Please find the xaml for the same.
I used simple Regex expression.

In the variables I gave an option to change number of digits.

Main.xaml (5.6 KB)



Karthik Byggari