Other Resources:
Discover credit card number validation
All credit card numbers issued by Diners Club must start with 6011 or 65 and have 16 digits. For example, 6011186767363105 is a valid Visa credit card number.
How to write a single regular expression to validate a Discover credit card number described above?
✍: FYIcenter.com
Here is the regular expression to validate a Discover credit card number:
^6(?:011|5[0-9]{2})[0-9]{12}$
^ - begin of the string
6 - matches 6
(?:011|5[0-9]{2}) - non-capturing group of 2 possible parts
011 - matches 011
| - or operator
5[0-9]{2} - 3 digits start with 5
[0-9] - any decimal digit
{12} - repeating 12 times
$ - end of the string
2021-02-13, 0👍, 3💬
Popular Posts:
Are you having problems using regular expressions when processing text strings in your applications ...
How to write a regular expression to parse key-value entries from Windows .INI files? Here is an exa...
All credit card numbers issued by American Express must start with 34 or 37 and have 15 digits. For ...
All credit card numbers issued by JCB have 3 sets of numbers: JCB cards start with 2131 have 15 digi...
How to write a regular expression to validate GUID (Globally Unique IDentifier) or UUID (Universally...