HI in this tutorial we will learn how we can split strings in array in UiPath using split string functions. Split string function is used to split a string in number of sub-strings by a given character called a separator. The parts of the strings are returned in an array.
In this example we have a string which contains days of week separated by a comma, like below
We want to separate these days in separate line. The output should be as below
The Day is Sunday The Day is Monday The Day is Tuesday The Day is Wednesday The Day is Thursday The Day is Friday The Day is Saturday
We will now go to UiPath and open a Sequence. and follow the below steps
First we will create a variable which will be of string type and we should call is strLongString which will hold our long string.
We need another variable of type array of string and we will call it arrSeparatedStrings
Now Drag and Drop the Assign activity from Activities Panel, and assign the long string to the variable strLongString.
We need another assign activity in which we will split the string and store the separated array in the variable arrSeparatedStrings. So let drag another assign activity and and on left side we will add the array variable arrSeparatedStrings and on right hand side we will use the Split(), it needs two parameter first parameter will the the string whcih we wan to split in this case it is strLongString and the second parameter is the separator, for us it is the comma(,).
The string is now has been splitted and stored in the variable arrSeparatedStrings
Now we need to print, the array has the list of the separated string so we will be using the for each activity to loop through the array and print.
So lets drag and drop the For Each activity from activity panel.and pass the array variable to for each.
And Inside the Body section of the for drag a Write Line activity and type “The Day Is ” + item.ToString, this will concatenate the string in quotes with the value of in the item variable.
Now lets run and check the output panel, and we should have the desired output.
Here is the Video tutorial for Split String in UiPath