Skip to content

Instantly share code, notes, and snippets.

@jadudm
Created February 6, 2013 14:17
Show Gist options
  • Save jadudm/4722762 to your computer and use it in GitHub Desktop.
Save jadudm/4722762 to your computer and use it in GitHub Desktop.
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