Tuesday, 3 September 2013

Extracting from File using Regular Expression

Extracting from File using Regular Expression

I have a text document that I would like to extract certain phrases from.
The phrase is "MmarC5_" followed by 4 numbers. This is what I have so far:
with open("file.txt") as f:
re = (MmarC5_)
re.findall(MmarC5_\d{4}", f.read())
I keep getting the error:
NameError: name 'MmarC5' is not defined.

No comments:

Post a Comment