I have an assignment that requires me to validate certain credit card formats using regular expressions. For example a MasterCard has 16 digits, starts with a 5 and is followed by 15 digits, so the regular expression would be as follows:
5[0-9]{15}
What would be the regular expressions for the following credit cards formats?
Diners Club: credit card has 14 digits and begins with either 301, 302, 303, 304, 305, 36 or 38.
JCB: credit card has either 15 digits beginning with either 2131 or 1800, or has 16 digits and begins with 35
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…