Skip to content

Instantly share code, notes, and snippets.

@wkta wkta/

Created Mar 31, 2014
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."
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.