Skip to content

Instantly share code, notes, and snippets.

@niklasl
Created March 17, 2010 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niklasl/335201 to your computer and use it in GitHub Desktop.
Save niklasl/335201 to your computer and use it in GitHub Desktop.
import re
regexps = [
r'\d\d',
r'^\d\d$',
r'^\d{2}$',
r'^\d{2,}$',
r'^\d{2,3}$',
r'^\d{2,4}$',
]
values = ["12", "123", "1234"]
for regexp in regexps:
print "Testing regexp:", regexp
for s in values:
print "Matches" if re.match(regexp, s) else "No match",
print "for value:", s
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment