Parse String


#1

I have a sample string with some info, lets say

Name:
Age:
Gender:

How can I parse everything after the colons of these main categories? I was considering to read character by character and stop at the end of the new line - which leads me to my next question. How do I determine when I am at a new line? I come from a ‘C’ background so I’m used to just checking if string[x] = ‘\n’ then … to check but I am not sure how to check in uipath/vb.


#2

String.split variable will create separate sub strings and will store it in a variable of array of strings.
Take an array of string variable as “aTest”. Assign it the value of string.split(":")
Then you can get the values of right hand by calling “aTest(1).ToString”,“aTest(3).ToString” & “aTest(5).ToString”.


#3

This gives me the value until the next “:” as well though. For example:

Name: user
Age:Sixty
Gender: Male

If I do string(1) it will give me user\nAge where I just want “user”


#4

@mkkajtez

Name: user
Age:Sixty
Gender: Male

This will be stored in one variable or different , different variables?


#5

Store those three lines in a string variable. In my example below it is TestString.

Then you can use the Assign activity to store the value of the Name in another variable.

TestString.Substring(TestString.IndexOf("Name: ")+"Name: ".Length).Split(Environment.NewLine.ToCharArray)(0)

Replicate for age and gender.

Example attached:

TestString_Parse.xaml (6.9 KB)


UiPath supports coding language VB and C# but when?