c# - Can i group a text file with Regex based on line patterns -


given file:

timestamp: text , number 1 timestamp: text , number 33 timestamp: text , number 1 timestamp: text , number 22 totally different, maybe new pattern timestamp: text , number 4 timestamp: text , number 2 totally different, maybe new pattern totally different, maybe new pattern 

i groupings of line 1 4(type1) , line 5(type2), line 6,7(type1) , line 8,9(type2).

can done in 1 regualar expression or should create 1 expression each type , check line line , if previous line same type?

at end need return list of groupings pair(int start_char, int end_char)

you can try this

string[] lines = system.io.file.readalllines("your taext file");         var groups =(                  w in lines                  group w w[0] g                  select new { firstletterline = g.key, lins = g });  

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -