After searching around the internet for Regex for UK Credit and Debit cards to pre validate data before being sent to the payment gateway I had to peice together loads of different regular expressions. So for future I thought I would put them all in one place for everyone to find.
If you notice any problems with these regular expressions please add a comment below.
Debit Cards (Switch / Solo / Maestro)
(^(5[0678])\d{11,18}$)(^(6[^05])\d{11,18}$)(^(601)[^1]\d{9,16}$)(^(6011)\d{9,11}$)(^(6011)\d{13,16}$)(^(65)\d{11,13}$)(^(65)\d{15,18}$)(^(49030)[2-9](\d{10}$\d{12,13}$))(^(49033)[5-9](\d{10}$\d{12,13}$))(^(49110)[1-2](\d{10}$\d{12,13}$))(^(49117)[4-9](\d{10}$\d{12,13}$))(^(49118)[0-2](\d{10}$\d{12,13}$))(^(4936)(\d{12}$\d{14,15}$))
Matches any of Solo, Switch or Maestro. International safe. Will not match on Discover, Visa or Mastercard.
Master Cards
^5[1-5]\d{14}$
Visa ( Includes Visa Electron )
(^4\d{12}$)(^4[0-8]\d{14}$)(^(49)[^013]\d{13}$)(^(49030)[0-1]\d{10}$)(^(49033)[0-4]\d{10}$)(^(49110)[^12]\d{10}$)(^(49117)[0-3]\d{10}$)(^(49118)[^0-2]\d{10}$)(^(493)[^6]\d{12}$)
Matches Visa CC types 13 or 16 digits starting with 4 including Visa CC, Visa ATM only, Visa Electron and Visa Delta.
Thursday, May 22, 2008
Regex for UK Credit / Debit Cards
Labels:
credit cards,
regex,
regular expressions
Subscribe to:
Post Comments (Atom)
1 comment:
[url=http://aluejxfttk.com]EdEvkoUyxyhiVWA[/url] , gifvrUkUbfY , http://iluubcb.com
Post a Comment