Elements that match a regular expression in a datatable

I am trying to validate if a certain element is repeated in a column of a datatable but since this element can contain different character combinations I use a regular expression to identify the pattern.

Is there a quick way to validate in the data table if a regular expression matches repeatedly? I am looking for a simplified way to do this as I am avoiding using a for each loop.

you can use one select query using the pattern as mentioned in below link:

1 Like

Here’s how you can do it in one line using an assign activity. The result of the below code is a boolean, true if every row in column 0 (1st column) matches a regex expression. You’ll need to add System.Text.RegularExpressions on your import list to avoid making this look too messy:

dt.AsEnumerable.All(function(r) regex.isMatch(r(0).ToString, "myRegexPattern"))
1 Like

Thank you @Greg_Jacobson , It Works fine!

1 Like

Great! I also realized I didn’t add regex before isMatch. Glad you knew to update though :wink:

1 Like

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