Created
February 6, 2013 14:17
-
-
Save jadudm/4722762 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
filecontents = ["Matt Purple 4", "Jan Green", "Gary Orange 7"] | |
regex = re.compile("(\w+)\s+\w+\s+\d+") | |
for line in filecontents: | |
r = regex.search(line) | |
if r: | |
print "Groups: " + str(r.groups()) | |
print "Matches: " + str(regex.findall(line)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment