Skip to content

Instantly share code, notes, and snippets.

@wkta
Created March 31, 2014 17:01
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 wkta/9896933 to your computer and use it in GitHub Desktop.
Save wkta/9896933 to your computer and use it in GitHub Desktop.
#MonthOfCode day 27 - pattern
import re
print "Testing your knowledge on regular expressions"
partterns = [
"a{4,}b", "Y.*g", "ro..c..ter", "[a,m,k]{5,8}" ]
for pat in partterns:
print "Try to type a string that matches the REGULAR EXPRESSION",pat
success = False
while True:
user_str = raw_input()
result = re.match( pat , user_str )
if( result!=None ):
print " OK."
break
print " Sorry, that doesn't match. Try again."
print "Congratulations! You've passed the test succesfully."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment