-5
我想使用正則表達式從文本文件中找到一個部分。我有文件,如下:正則表達式來查找文本文件的特定部分
This is general text section that I don't want.
HEADER:ABC1
This is section text under header
More text to follow
Additional text to follow
HEADER:XYZ2
This is section text under header
More text to follow
Additional text to follow
HEADER:KHJ3
This is section text under header
A match text will look like this A:86::ABC
現在,我想檢索所有文字部分高達HEADER
如果部分文本包含匹配A:86::ABC
。結果文本將是
(HEADER:KHJ3
This is section text under header
A match text will look like this A:86::ABC).
我感謝任何幫助。我使用python,並且匹配部分可以在文件中多於一個。這也是一個多行文件。
您使用哪種編程語言? – user4035