Regex results to a 1 column datatable

Greetings,

I have successfully transferred regex results to datatables via:

  • build datatable
    • for each item in matches
      • add data row as an array
        • item.value.replace/split

However, I am getting stuck on trying to put each line (denoted by a blue dot next to it) in a row, in a 1 column datatable

Keep in mind, the regex used to capture this was:

System.Text.RegularExpressions.Regex.Match(QuoteTxt,"Item Description[\s\S]+?Final Quote").Value

So, if I try to use the method of row count = regex count, it is giving a very high number.

I really appreciate the help.

Thank you so much!

1 Like

Hey @Sc100

Your pattern would be matching everything from start to finish. You want to match line by line?

If yes, try this regex pattern:

System.Text.RegularExpressions.Regex.Match(QuoteTxt,“^.*”).Value

Hopefully this helps :slight_smile:

Cheers

Steve

1 Like

Hi Steve,

Thank you for the answer, it definitely captures a line.

I added [^.*] so it captures all of the lines.

However, when I do the matches. count, it is still counting each individual letter/character, and not counting the lines.

I am getting a count of 500, but it should really be a count of 20.

Any ideas?

Looking at Regextester site,

I got what I was looking for when I selected these flags:

However, selecting multiline in the Matches activity settings, it is not selecting all the lines like the regextester website:

Thank you in advance!

Hi @Sc100 ,

Have you tried executing with that settings/Regex Expression ? It does not necessarily indicate always the capturing of all the lines.

Check by executing first and let us know if you are still not able to get the results.

1 Like

Hey, that did it.

Thank you for the tip!

Also, big shout out to Steve for stepping in with the regex pattern!

You both helped a ton.

1 Like

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