Python 正则表达式验证信用卡号码

Rule:

Visa 
  13 or 16 digits, starting with 4
MasterCard
  16 digits,starting with 51 through 55
Discover
  16 digits,starting with 6011 or 65
American Express
  15 digits,starting with 34 or 37
Diners Club
  14 digits,starting with 300 through 305,36 or 38
JCB
  15 digits,starting with 2131 or 1800, or 16 digits starting with 35

(?x)^(?:
(?P4[0-9]{12}(?:[0-9]{3})?) |
(?P5[1-5][0-9]{14}) |
(?P6(?:011|5[0-9]{2})[0-9]{12}) |
(?P3[47][0-9]{13}) |
(?P3(?:0[0-5]|[68][0-9])[0-9]{11}) |
(?P(?:2131|1800|35[0-9]{3})[0-9]{11})
)$

你可能感兴趣的:(编程语言)