Regex Question
Thomas Güttler
guettler at thomas-guettler.de
Wed Aug 20 10:55:57 EDT 2003
Hi!
I want to parse a file that looks like this:
a0001: basbasdb
asbddsb
asdbasdb
abasbd
a0002: fffff
ffff
ffffff
ffff
a???? should be the key and the following lines should
be the value of a dictionary.
My solution looks like this:
regex=re.compile(r'(?:^|\n)(\w\d\d\d\d):((?:.(?!\n\w\d\d\d\d:))*)',
re.DOTALL)
matches=regex.findall(content)
for match in matches:
print match
I think there is a better solution than this, don't you?
thomas
More information about the Python-list
mailing list