Creating data table using regex

Good morning
I’m attempting to build a data table using REGEX. I need to place the “groups” into the columns on the data table. Any assistance will be appreciated. Thanks!

group 1 - Agency
2 - GBL
3 - TRANSID
4 - EMP NAME

image

image

image

Hi

Hope the below steps would help you resolve

  1. Once after using Matches activity or with an expression the output of Matches activity will return an IEnumerable<Match> and Match has a Groups method which returns a GroupCollection.

So if my activity output variable was matchOut and I wanted to get the first group in the first match instance, I would need:

matchOut(0).Groups(1).Value

Use the same for all in a ADD DATAROW ACTIVITY

  1. Say your datatable name is dt
    Now use a FOR EACH activity and pass the above matches varivale as input and change the type argument as System.Text.RegularExpressions.Regex.Match

  2. Inside the loop use a Add Datarow activity and mention in ArrayRow property like this

{matchOut(0).Groups(1).Value, matchOut(0).Groups(2).Value, matchOut(0).Groups(3).Value, matchOut(0).Groups(4).Value}

And in datatable property mention as dt

Cheers @gustavo_marrufo

Hi,

If result of the Matches activity has some Match instances and you want to input them to the datatable, the following expression might help you.

dt = matchesResult.Select(Function(m) dt.Clone.LoadDataRow(m.Groups.Cast(Of Group).Select(Function(g) g.Value).Skip(1).ToArray,False)).CopyToDataTable

Regards,

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.