title

Useful regex : crédit cards

 

Useful regex : crédit cards

29 Avr 2013, Posted by antoine in

//Credit card: All major cards
‘^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})$’

//Credit card: American Express
‘^3[47][0-9]{13}$’

//Credit card: Diners Club
‘^3(?:0[0-5]|[68][0-9])[0-9]{11}$’

//Credit card: Discover
‘^6011[0-9]{12}$’

//Credit card: MasterCard
‘^5[1-5][0-9]{14}$’

//Credit card: Visa
‘^4[0-9]{12}(?:[0-9]{3})?$’

//Credit card: remove non-digits
‘/[^0-9]+/’