Posted By

ronakpatel2006 on 08/11/11


Tagged

check regular Expression mdn


Versions (?)

CHeck the length of the mdn


 / Published in: Python
 

  1. import re
  2. def check_mdn(mdn, mdn_re = re.compile('^\d{10,15}$')):
  3. ''' Check if MDN is acceptable
  4. '''
  5.  
  6. print " MDN: %s " % mdn
  7. if mdn_re.match(str(mdn)):
  8. print " %s is fine " % mdn
  9. return True
  10. else:
  11. print " %s is not fine" % mdn
  12. return False
  13.  
  14.  
  15. mdn = '1234'
  16. mdn1 = '1212121212'
  17. mdn12= '121212121212'
  18. mdn15= '121212121212121'
  19. mdn18= '123456789012345678'
  20.  
  21. check_mdn(mdn)
  22. check_mdn(mdn1)
  23. check_mdn(mdn12)
  24. check_mdn(mdn15)
  25. check_mdn(mdn18)

Report this snippet  

You need to login to post a comment.