Created
September 7, 2012 00:15
-
-
Save pythonjunkie/3661745 to your computer and use it in GitHub Desktop.
Validate length of a phone number
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 | |
def check_mdn(mdn, mdn_re = re.compile('^\d{10,15}$')): | |
''' Check if MDN is acceptable | |
''' | |
print " MDN: %s " % mdn | |
if mdn_re.match(str(mdn)): | |
print " %s is fine " % mdn | |
return True | |
else: | |
print " %s is not fine" % mdn | |
return False | |
mdn = '1234' | |
mdn1 = '1212121212' | |
mdn12= '121212121212' | |
mdn15= '121212121212121' | |
mdn18= '123456789012345678' | |
check_mdn(mdn) | |
check_mdn(mdn1) | |
check_mdn(mdn12) | |
check_mdn(mdn15) | |
check_mdn(mdn18) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment