给定一个文件:
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)的分组。
这可以在一个正则表达式中完成,还是我应该为每种类型创建一个表达式,然后逐行检查前一行是否为同一类型?
最后,我需要返回一个带有 pair(int start_char, int end_char) 的分组列表