Create a list of Regex Matches

Hi all,

I’m trying to build a RegEx engines that runs multiple expressions on a certain string input. I would like to store all expressions on a central repository so I could add/change/delete some later on.

What I’m looking for is a way to store the output of each regex match in a dynamic list. I saw that the standard variable is IEnumerable, so I created List <IEnumerable>. My issue is trying to initialize that list. I created an assign activity with xListx= new list (of …), but I don’t know what to write between the brackets.

Can someone point me in the right direction?

Hi there @MatthiasVG,
I’m not sure I’ve understood your question, but I believe the output of ‘Matches’ is:

System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Match>

And thus, you should be able to initialise a list of the above via:

New List(Of System.Collections.Generic.IEnumerable(Of System.Text.RegularExpressions.Match))

Thanks,
Josh

2 Likes

Davey, you’re my hero :slight_smile:
Works like a charm!

1 Like

Hi @Mr_JDavey,

I am curious if this is something that I can put into assign or is it just an explanation?
i am looking for a solution to put the result of the match into a list instead of using the for loop, and join and split. If you have better idea, please let me know thanks!

An array not a list actually…

Thanks

Lavina