We’ve all seen (and probably used) one of the many regex patterns for validating various credit cards…
Are there any “OFFICIAL” regex patterns published by the card companies themselves?
Are these patterns all simply submitted by the community?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is no regex pattern that can perfectly validate a card number. The various solutions that are out there are very basic checks that cover the first few digits only. In reality there are often huge gaps within those ranges where cards have not yet been assigned by any card issuer.
You can sanity check the first few digits, card length and luhn check digit, but the only way to completely validate a card is to submit it to the processor for validation and authorization.