我想提取两种模式之间的线条(例如,模式 1 和模式 2)。该文件的结构如下:
a random number of lines containing other stuff
pattern1
some lines to be extracted (finding out the number of lines possible, if necessary)
pattern2
a random number of lines containing other stuff
pattern1
some lines to be extracted
pattern2
a random number of lines containing other stuff
这会重复很多次(即存在大量匹配的pattern1-pattern2 对)。我想提取所有匹配模式之间的线条,有效地丢弃随机的东西。
我怎样才能做到这一点?