Skip to content

Instantly share code, notes, and snippets.

@wkta wkta/day_27.py
Created Mar 31, 2014

Embed
What would you like to do?
#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
You can’t perform that action at this time.