DataTable match only rows with 6 digits in Column0

Hi,

I need to keep in datatable only rows where “Column0” contains 6 digits.

What is wrong with following statement?

dt = dt.AsEnumerable().Where(Function (row) row(“Column0”).ToString.
Equals(System.Text.RegularExpressions.Regex.Match(row(“Column0”).ToString,“[1]{1,6}$”))). CopyToDataTable()

Thx for suggestions and kind regards,
Vanja


  1. 0-9 ↩︎

Better like this:

dt = dt.AsEnumerable().Where(Function (row) System.Text.RegularExpressions.Regex.IsMatch(row("Column0").ToString,"[0-9]{6}$")). CopyToDataTable()

And alos check this post

Cheers

1 Like

Hi @VanjaV

How about this expression

dt.AsEnumerable().Where(Function(s) System.Text.RegularExpressions.Regex.IsMatch(s("Column2").ToString,"\d{6}")).Select(Function(a) a).CopyToDataTable

image

Or

dt.AsEnumerable().Where(Function(s) s("Column2").ToString.Trim.Length.ToString.Equals("6")).Select(Function(a) a).CopyToDataTable

image

Regards
Sudharsan

1 Like

Hello @VanjaV

Have you checked the same with filter datatable activity?

Thanks

1 Like

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