Skip to content

Instantly share code, notes, and snippets.

@hojberg
Created March 10, 2010 09:05
Show Gist options
  • Save hojberg/327703 to your computer and use it in GitHub Desktop.
Save hojberg/327703 to your computer and use it in GitHub Desktop.
# http://en.wikipedia.org/wiki/Bank_card_number
CARDTYPES = {
:visa => /^4(?!571|917|913|508|844|17500)[0-9]{12,15}$/,
:mastercard => /^5(?!4130380)[1-5][0-9]{14}$/,
:dinersclub => /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/,
:amex => /^3[47][0-9]{13}$/,
:discover => /^6(?:011|5[0-9]{2})[0-9]{12}$/,
:visadankort => /^4571[0-9]{12}$/,
:dankort => /^5019[0-9]{12}$/,
:eurocardbyinvitation => /^54130380\d{8}/,
:visaelectron => /(^(4917|4913|4508|4844|)\d{12}$)|^(417500)[0-9]{10}$/,
:maestro => /^(5018|5020|5038|6304|6759|6761|6763)\d{8,15}$/,
:jcb => /^(?:2131|1800|35\d{3})\d{11}$/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment