"Split String" Activity

Hi Team,

How to use split string activity ?

I tried giving the input as a string variable consisting of a value, and the result as an array of string.

Input: “DE-123”
Result: test
separator: “-”

I tried printing the test as test.ToString but it is giving as System.String.

Please help asap.

Thanks in advance
Dileep. S


Hey @dileeps

Try this :slight_smile: split_string_activity.xaml (5.3 KB)

It returns a String[] array so to get values you have to access them by using array index.

Regards…!!
Aksh

4 Likes

Hi @aksh1yadav

Thanx man. Thats totally working fine. :slight_smile:

Regards
Dileep

hi @aksh1yadav,

Can you please help me in this.

I am reading a string from the screen, and using split string i divided the string.

“LU - LUXEMBOURG”
using split string and delimiter as " - " which results in LU and LUXEMBOURG. I want to use the second string. So as you mentioned above i assigned riskgeo(1).tostring to a variable.

But, this is not working fine at times and getting the below mentioned error in the workflow. If I run the same workflow again without any changes, it works fine.

Please help me. Find the image below.

Thanks
Dileep. S

Its a good practice to validate the existence of data before you perform split.In your case, get text variable.

for eg:

if(string.IsNullorEmpty(str))

if(str.Contails("-"))

arrstr = Split(str,"-")

if(arrstr.length> 1)

Name = arrstr(1).Tostring
3 Likes

Hi @vvaidya

The string will not be empty. After posting the above error, I just ran the workflow and it worked fine :confused:

So, and the string will not be empty. what else do you want me to check. The workflow is getting stopped at the assign activity.

Regards
Dileep. S

if(str.Contails(“-”))

arrstr = Split(str,“-”)

if(arrstr.length> 1)

Just make sure the data is not empty. so may be get text is not able to get data everytime may be page load uncomplete or internet slow connection. use write line to check data is coming or not and put conditions before it to make sure no error as @vvaidya mentioned.

Yea guys… I have checked. get text is work is not working fine because the indexes are being changed from time to time.

Thanks for your suggestions :slight_smile:

Regards
Dileep. S

Many thanks, this example helped me a lot!

Split string activity is not included in 2018 studio, does anyone know why?

1 Like

Even we are facing same issue. The workflows developed in older versions of UiPath & opened in newer versions, which is showing error in existing activities position even though activity is already imported and available in activities pane. Let us know how to eliminate this error .

Regards,
Shreekrishna

Any Update on this?