与えられたファイル:
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
1 行目から 4 行目 (TYPE1) と 5 行目 (TYPE2)、6 行目と 7 行目 (TYPE1) と 8 行目と 9 行目 (TYPE2) のグループを取得したいと考えています。
これは 1 つの正規表現で行うことができますか、それとも型ごとに 1 つの式を作成してから、行ごとに前の行が同じ型であるかどうかを確認する必要がありますか?
最後に、ペアでグループ化のリストを返す必要があります(int start_char, int end_char)