On Wed, 13 Jan 2010 23:05:11 -0000
"Alan Gauld" <[email protected]> wrote:
> But a third option is to use a split and apply it to the whole file as
> a string thereby breaking the file into as many chunks as start with
> a line containing 'NEW'...
Why not simply a regex pattern starting with "NEW" and ending with '\n'?
import re
pat = re.compile("""NEW(.+)\n""")
source = "abc\defNEWghi\njkl\nmno\nNEWpqr\nstu\n"
print pat.findall(source)
# ==> ['ghi', 'pqr']
Denis
________________________________
la vita e estrany
http://spir.wikidot.com/
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor