/ Published in: Python
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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)