How to check the number of strings that match a format in a certain column of a DATATABLE without using loops?

Hi,

How to check the number of strings that match a format in a certain column of a DATATABLE without using loops?
The format is as follows"A**-***"

ID Code
A AB-776
B ABC-123
C BBB-666
D DDD-8888

Hi @rockchord

matchingCount = (From row In dt.AsEnumerable()
                 Where System.Text.RegularExpressions.Regex.IsMatch(row("Code").ToString(), "(A.*)")
                 Select row).Count()

Regards,

Hi @rockchord

=> Read Range Workbook
Output: dtData

=> Use below syntax in Assign:

Assign -> matchCount = dtData.AsEnumerable().Count(Function(row) System.Text.RegularExpressions.Regex.IsMatch(row("Code").ToString(), "^A..-...$"))

matchCount is of DataType System.Int32

=> Print matchCount in Write Line or Log Message.

Regards

@rockchord

Regards,

@vrdabberu

I can’t thank you enough.
It worked fine.

@lrtetala

Thank you very much for your response.

1 Like

You’re welcome @rockchord

Happy Automation!!

1 Like

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