Could anyone help me with the below challenge I am undergoing in my project.
I have a excel sheet, which has the Column called “transid”. It has the four kinds of pattern data in it(eg: 111,1A1,A11,1AA). Now, I want to filter the data based up on the pattern and move them into different files.
This might be a better solution, using Pattern and Lambda/LINQ to create your filtered datatable.
dtVar.AsEnumerable().Where(Function(row) row(“transid”).ToString=System.Text.RegularExpressions.Regex.Match(row(“transid”).ToString,“[0-9][A-Z]{2}”).Value or row(“transid”).ToString=System.Text.RegularExpressions.Regex.Match(row(“transid”).ToString,“[0-9][A-Z][0-9]”).Value or row(“transid”).ToString=System.Text.RegularExpressions.Regex.Match(row(“transid”).ToString,“[A-Z][A-Z][0-9]”).Value or row(“transid”).ToString=System.Text.RegularExpressions.Regex.Match(row(“transid”).ToString,“[0-9]{3}”).Value).CopyToDatatable
or change .CopyToDatatable to .ToArray
This line should filter down to the rows that meet the criterias of 3 numbers, 2 numbers and a letter, or 1 number and 2 letters. Of course there is lot more you can do with this, and feel free to correct this or add to it.
EDIT: Oh also, if you want to move each criteria to a different file, then remove the "or"s and create a line for each filtered criteria that you want.