Split a string and get the first and the last element using the UiPath. This is helpful in directly splitting a string using a single char and get the value.
Add a new Assign activity and initialize a new string variable with a sample value. My variable name is
name and its value is
I will split the name variable using space and print the first and second path of the string on the output console using the Write Line activity. Below is the expression I will be using to get the first and last element of a string in UiPath.
name.Split(" "c).First name.Split(" "c).Last
If you want to split the string based on a special character, for example, hyphen (-). Then your expression will be as shown below.
Below is the complete flow for this example.
In both examples, the output will be the same.
You must be logged in to post a comment.