Merge MatchCollection variables

I extracted tabular information from multiple PDF files using Regex. How can I merge these MatchCollection variables? I have tried variable.Cast(OF Match)().Union(variable.Cast(OF Match)()).ToList() in a ForEach but it threw an exception. Thank you.

Hi @Li_Eric

Can you try the below syntax:

combinedList As List(Of Match) = matchCollection1.Cast(Of Match)().Concat(matchCollection2.Cast(Of Match)()).Distinct().ToList()

Hope it helps!!
Regards

@mkankatala Thank you for your prompt reply.
Since this expression will be in a ForEach activity, I modify it as below, and the initial matchCollection1 should be empty. But it still doesn’t work.
`


image