Validating Credit Card Numbers
After you’ve graciously stripped out spaces and dashes, you can check whether the card number looks like a valid number and even determine the brand of the card with a few simple regular expressions. I’ve published a new article on finding and verifying credit card numbers on regular-expressions.info with some in-depth information and a full set of example regexes.
Do these credit card numbers also contain a checksum number at the end? I know my belgian banck card nr does. If this is the case than, as for as my regex knowledge goes, it can’t be checked by a regex.
Comment by Tom Pester — Sunday, 30 March 2008 @ 15:24
The checksum number is calculated with the Luhn algorithm that I mentioned in my article.
You indeed can’t check that with a regex.
Comment by Jan — Monday, 31 March 2008 @ 8:26