Reputation: 17560
Given a file:
Timestamp: some text and a number 1
Timestamp: some text and a number 33
Timestamp: some text and a number 1
Timestamp: some text and a number 22
Something totally different, maybe a new pattern
Timestamp: some text and a number 4
Timestamp: some text and a number 2
Something totally different, maybe a new pattern
Something totally different, maybe a new pattern
I would like to get groupings of line 1 to 4(TYPE1) and line 5(TYPE2), line 6,7(TYPE1) and line 8,9(TYPE2).
Can this be done in one regualar expression or should i create one expression for each type and then check line by line and if the previous line is the same type?
At the end i need to return a list of groupings with pair(int start_char, int end_char)
Upvotes: 1
Views: 102
Reputation: 13599
you can try this
string[] lines = System.IO.File.ReadAllLines("your taext file");
var Groups =(
from w in lines
group w by w[0] into g
select new { FirstLetterLine = g.Key, Lins = g });
Upvotes: 1