我試圖從兩行之間存在的文件中抓取一段文本。具體來說,我需要能夠抓住一條線和所有以下線路,直到另一條特定線路。返回匹配日期和時間後的所有行,但不包括下一個日期和時間?
例如,原始文件將包含類似這樣:
Aug 23, 2011 10:31:35 AM This is the start of the text.
This is more Text.
This is another line
This is another line
This is more.
Aug 23, 2011 10:41:00 AM This is the next in the series.
This is another line
This is more Text.
This is another line
This is another line
This is more.
Aug 24, 2011 10:41:00 AM This is the next in the series.
This is another line
This is more Text.
This is another line
This is another line
This is more.
,我需要它通過分析和迴歸:
Aug 23, 2011 10:31:35 AM This is the start of the text.
This is more Text.
This is another line
This is another line
This is more.
沒有人有任何建議的方法來實現這個?
簡單的readline循環,停在包含'系列中的下一個'的行 – kusut
編輯你的問題與你試過人們會很樂意幫助您解決問題。 –
去閱讀:[正則表達式HOWTO](http://docs.python.org/howto/regex.html)這是你需要的 – prince