Add matches to a list (regex)

I am trying to add all of the matches from a regex match activity to a list and reference the matches later. However I am having trouble storing the output of the match regex activity as a list. How would I assign each input into an indexable list?

Can you show a snippet of what you have tried?

The matches activity has an Output property to store the result to an enumerable of matches, which would be your list. Then, you can manipulate or use that enumerable as you wish after.

You can also opt to use .net for matches which is just System.Text.RegularExpressions.Regex.Matches(text, pattern) which is the same thing.

You can also add .ToList or .ToArray on the end of the enumerable to store it to a specific data type.

Regards.

“Out_matches” is the enumerable from the match activity and “Names” is a list of strings that I would like to add the different matches too.

In your Assign, I think you need to pull in the string value of each match. Or change Names to a List of Matches.

To get the matches in a list of strings to assign to Names, try this:
Out_Matches.Select(Function(x) x.Value).ToList

This way you get the Value of each Match from the enumerable, which are strings.

Regards.

1 Like