#MonthOfCode day 27 - pattern
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 | |
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