Financial Accounts
Credit cards
If using the regular expressions below for a Blackout image project, results may be improved by being defensive against common OCR mistakes. Each instance of the any digit match can be replaced with a character replacement pattern that will evaluate numbers as common alphanumeric characters.
To do so simply replace the \d
pattern with [\dOIlZEASB]
. This type of defensive matching is not typically needed for Excel.
Visa, MasterCard, AmEx
\b((4\d{3}|5[1-5]\d{2}|2\d{3}|3[47]\d{1,2})[\s\-]?\d{4,6}[\s\-]?\d{4,6}?([\s\-]\d{3,4})?(\d{3})?)\b
This regular expression matches the following samples.
Visa
- 4532613257548007
- 4716563756075937
- 4929038415234561233
- 4718 4123 4142 4124
- 4716-5637-5607-5937
MasterCard
- 2720-9928-3988-7281
- 2720992839887281
- 5461718001676921
- 5489790994470834
- 5489 7909 9447 0834
- 5489-7909-9447-0834
AmEx
- 372714876128394
- 346781676352683
- 376506566639896
- 3765 065666 39896
- 3467 816763 52683
- 3400 0000 0000 009
Individual brand credit cards
Card | Regex |
---|---|
Amex Card | \b3[47][0-9]{13}\b |
BCGlobal | \b(6541|6556)[0-9]{12}\b |
Carte Blanche Card | \b389[0-9]{11}\b |
Diners Club Card | \b3(?:0[0-5]|[68][0-9])[0-9]{11}\b |
Discover Card | \b65[4-9][0-9]{13}|64[4-9][0-9]{13}|6011[0-9]{12}|(622(?:12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|9[01][0-9]|92[0-5])[0-9]{10})\b |
Insta Payment Card | \b63[7-9][0-9]{13}\b |
JCB Card | \b(?:2131|1800|35\d{3})\d{11}\b |
Korean Local Card | \b9[0-9]{15}\b |
Laser Card | \b(6304|6706|6709|6771)[0-9]{12,15}\b |
Maestro Card | \b(5018|5020|5038|6304|6759|6761|6763)[0-9]{8,15}\b |
MasterCard | \b(?:4[0-9]{12}(?:[0-9]{3})?|[25][1-7][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})\b |
Solo Card | \b(6334|6767)[0-9]{12}|(6334|6767)[0-9]{14}|(6334|6767)[0-9]{15}\b |
Switch Card | \b(4903|4905|4911|4936|6333|6759)[0-9]{12}|(4903|4905|4911|4936|6333|6759)[0-9]{14}|(4903|4905|4911|4936|6333|6759)[0-9]{15}|564182[0-9]{10}|564182[0-9]{12}|564182[0-9]{13}|633110[0-9]{10}|633110[0-9]{12}|633110[0-9]{13}\b |
Union Pay Card | \b(62[0-9]{14,17})\b |
Visa Card | \b4[0-9]{12}(?:[0-9]{3})?\b |
Visa Master Card | \b(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14})\b |
American Banker Association (ABA) transit routing numbers
\b((0[0-9])|(1[0-2])|(2[1-9])|(3[0-2])|(6[1-9])|(7[0-2])|80)([0-9]{7})\b
This regular expression matches the following ABA routing numbers.
011103093
- Florida
067014822
- Maine
211274450
- Massachusetts/Rhode Island
211370545
- Metro DC/Maryland/Virginia
054001725
- New Hampshire
011400071
- New Jersey/Delaware
031201360
- New York – Metro NYC or former Commerce customers
026013673
- New York – Upstate NY or former Banknorth customers
021302567
- North Carolina/South Carolina
053902197
- Pennsylvania
036001808
- Vermont
011600033
SWIFT Code
This regular expression can be used to redact SWIFT codes for payment instruction information.
\b[A-Z]{6}[A-Z0-9]{2}([A-Z0-9]{3})?\b
IBAN Codes
This regular expression can be used to redact IBAN codes for payment instruction information.
(?:(?:IT|SM)\d{2}[\w]\d{22}|CY\d{2}[\w]\d{23}|NL\d{2}[\w]{4}\d{10}|LV\d{2}[\w]{4}\d{13}|(?:BG|BH|GB|IE)\d{2}[\w]{4}\d{14}|GI\d{2}[\w]{4}\d{15}|RO\d{2}[\w]{4}\d{16}|KW\d{2}[\w]{4}\d{22}|MT\d{2}[\w]{4}\d{23}|NO\d{13}|(?:DK|FI|GL|FO)\d{16}|MK\d{17}|(?:AT|EE|KZ|LU|XK)\d{18}|(?:BA|HR|LI|CH|CR)\d{19}|(?:GE|DE|LT|ME|RS)\d{20}|IL\d{21}|(?:AD|CZ|ES|MD|SA)\d{22}|PT\d{23}|(?:BE|IS)\d{24}|(?:FR|MR|MC)\d{25}|(?:AL|DO|LB|PL)\d{26}|(?:AZ|HU)\d{27}|(?:GR|MU)\d{28})