* 'struct-like' list *
Ernesto
erniedude at gmail.com
Tue Feb 7 09:50:14 EST 2006
Thanks for the approach. I decided to use regular expressions. I'm
going by the code you posted (below). I replaced the line re.findall
line with my file handle read( ) like this:
print re.findall(pattern, myFileHandle.read())
This prints out only brackets []. Is a 're.compile' perhaps necessary
?
Raymond Hettinger wrote:
> # Approach for more loosely formatted inputs
> import re
> pattern = '''(?x)
> Name:\s+(\w+)\s+
> Age:\s+(\d+)\s+
> Birthday:\s+(\d+)\s+
> SocialSecurity:\s+(\d+)
> '''
> print re.findall(pattern, inputData)
More information about the Python-list
mailing list