Last active
December 12, 2015 05:38
-
-
Save jadudm/4722709 to your computer and use it in GitHub Desktop.
A quick example regarding regexps.
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("\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