Hi guys I have a set of 39 values within a Matche’s variable, and what I want to do is iterate through them assigning each value to a string variable to place into Excel rows. This is what I’m thinking of doing, and then adding ‘vCount = vCount + 1’ each time it loops through.
If they’re in a list you can loop over them using the For Each activity and use the index property on the activity as the counter. Just be aware that index starts at 0, so when you write to excel you want index+1 (or index+2 if you have a heading).
Hi
Instead we can pass that output variable from MATCHES to a FOR EACH activity and mention the type argument as System.Text.RegularExpressions.Match
Inside the loop we can access each match like this in a assign activity str_output = item.ToString
Hi @Palaniyappan can you explain that a bit more specifically, as I’m brand new to UiPath. So my matches varable is called vSubStringIndexArray, and I have the for loop setup for each ‘item’ in ‘vSubStringIndexArray’. Now I just need to know what to put in the ‘index’ option of the activity so it starts at an index of 1 and how to get those values into excel.
Fine
Let the variable name be vSubStringIndexArray
And pass this as input to FOR EACH activity
And as we need to access each element in this matches activity we have to change the type argument of the object only then we will be able to access them.
Accessing means directly the element and not with index position, as we are already iterating them in FOR EACH loop so that each element can be obtained in order of index position
For that in for each activity change the type argument property as System.Text.RegularExpressions.Match
—then inside the loop use a assign activity and mention like this
str_output = item.ToString
Here we don’t need to mention the index position rather it will get the value in order one by one
Yah inside the same for each loop instead of assign activity use a ADD TO COLLECTIONS activity
And mention the input as item.ToString in item property and in collections property mention as list_variable
Where list_variable is of type System.Collections.Generic.List(of string) with default value as New list(of string) defined in the variable panel
—now all the values from matches will be added to that list variable
—next to this for each loop use a assign activity like this list_variable = list_variable.Distinct().ToList()