Split and Trim the string

Hi All,

I have one string Shared preference:Mail and I want to get only mail and remove the shared preference. so how can I do it.

Please give me any solution


You can use substring to retrieve the part of the string after a certain character

Assign - Text (Type String) = "Shared preference:Mail"
Text.Substring(Text.IndexOf(":"c) + 1)

Hi, you can use an split:


ArrayResult = (“Shared preference:Mail”).Split(New char() {":"c})


then take the number 1 of the split:

thanks @Caduar for your help
but gives me error so if it is possible can you share a example of it.

I will assume your string “Shared preference:Mail” is in a variable called str1 of type string.

created a new string variable: MyString = str1.Split(":"c)(1)

This takes your string variable, and splits it into an array of strings based on the colon (:) character. Since your string has 1 colon in it, it will bring it into an array of 2 strings. The first one (index = 0) will be “Shared preference” and the second one (index = 1) will be “Mail”

1 Like

thanks @Dave

I have tried but it does not give me the solution.
could you please share the example in uipath.

What isn’t working? I went ahead and uploaded the file, but it is exactly the same as what i wrote above
Main.xaml (5.4 KB)

1 Like

thanks @Dave

now its working