说我有一个文本文件,其内容类似于以下内容:
021 Line one of section A.
021 Line two of Section A.
021 Line three of section A.
021 Part two of Line three of Section A.
021 We just skipped line four, but that's okay.
021 Back to line six.
Non-formatted lines to be ignored. This can be from 0 lines, to any number of lines, and the content can be any text.
033 Line 1 of Section B
033 Line 2 of Section B
033 Okay, that's enough.
在正则表达式中是否可以给我两组,第一组包含以021
开头的所有行,第二组包含以033
开头的所有行?
行标记会有所不同,但始终为\d{3}
。
答案 0 :(得分:1)