Displaying page
of
pages;
Items to
Title |
Test
Details
Credit Card: Visa + MC
|
Expression |
^(5[1-5]\d{2})\d{12}|(4\d{3})(\d{12}|\d{9})$
|
Description |
A simple regex to check for only Visa and MasterCard with no dashes or spaces. Visa starts with a 4 and is 13 or 16 digits long, MasterCard starts with a 51 through 55 and is 16 digits long. I noticed that some of the other formulas don't account for Visa being valid with only 13 digits. I used this for a PayPal processor (which doesn't allow dashes or spaces) and modified it from others on this site. Enjoy.
|
Matches |
5555555555554444 | 5105105105105100 | 4012888888881881 | 4222222222222
|
Non-Matches |
123412341234 | 4222-2222-2222-2222 | visa | 41231234123412345
|
Author |
Rating:
Not yet rated.
Dan Partain
|
Displaying page
of
pages;
Items to