Credit Card Number

There is a stand-alone regex policy for Credit Card Number(s), but several other policies use the same algorithm as an identifier for PII. It identifies potentially valid credit card numbers using the Luhn algorithm. Lenient, Moderate and Strict Tolerances are supported with Strict Tolerance as the default.

Lenient Tolerance

  • Luhn check applied
  • No proximity requirement
  • Common patterns accepted:
    1800\d{11}, 4\d{12}, 2131\d{11}, 2014\d{11}, 2014 \d{6} \d{5}, 2014-\d{6}-\d{5}, 2014. \d{6}. \d{5}, 2149\d{11}, 2149 \d{6} \d{5}, 2149-\d{6}-\d{5}, 2149. \d{6}. \d{5}, 3[068]\d{12}, 3[068]\d{2} \d{6} \d{4}, 3[068]\d{2}-\d{6}-\d{4}, 3[068]\d{2}. \d{6}. \d{4}, 3[47]\d{13}, 3[47]\d{2} \d{6} \d{5}, 3[47]\d{2}- \d{6}-\d{5}, 3[47]\d{2}. \d{6}. \d{5}

Accepts 16-digit and some 15-digit numbers in groups separated by a space, dash, period, or without separation.
• [1-9]\d{15}
• [1-9]\d{3} \d{4} \d{4} \d{4}
• [1-9]\d{3}-\d{4}-\d{4}-\d{4}
• [1-9]\d{3}. \d{4}. \d{4}. \d{4}

Moderate Tolerance

  • Luhn check applied
  • No proximity requirement
  • Accepts common patterns (listed in Lenient Tolerance)
  • Accepts 16-digit and some 15-digit numbers in groups separated by a space, dash, or period, or without separation, for specified card issuers

JCB

Regex
Examples

3\d{15}

3123456789012345

3\d{3} \d{4} \d{4} \d{4}

3123 4567 8901 2345

3\d{3}-\d{4}-\d{4}-\d{4}

3123-4567-8901-2345

3\d{3}. \d{4}. \d{4}. \d{4}

      1. 2345

VISA

Regex
Examples

4\d{15}

4123456789012345

4\d{3} \d{4} \d{4} \d{4}

3123 4567 8901 2345

4\d{3}-\d{4}-\d{4}-\d{4}

3123-4567-8901-2345

e. g. 3123. 4567. 8901. 2345

      1. 2345

Mastercard

Regex
Examples

5[1-5]\d{14}

5423456789012345

5[1-5]\d{2} \d{4} \d{4} \d{4}

5423 4567 8901 2345

5[1-5]\d{2}-\d{4}-\d{4}-\d{4}

5423-4567-8901-2345

5[1-5]\d{2}. \d{4}. \d{4}. \d{4

      1. 2345

Discover

Regex
Examples

6011\d{12}

6011123456789123

6011 \d{4} \d{4} \d{4}

6011 1234 5678 9123

6011-\d{4}-\d{4}-\d{4}

6011-1234-5678-9123

6011. \d{4}. \d{4}. \d{4}

      1. 9123

Excludes the following from being returned as matches as they are not in general use:

201400000000009

30175572836108

3088272824427380

341132368578216

3530111333300000

371449635398431

38520000023237

378282246310005

210002956344412

30569309025904

340000000000009

4716733846619930

4539687075612974

4539399050593

4222222222222

4024007116284

214906110040367

869989278167071

869908581608894

6011111111111110

5555555555554444

5455780586062610

5263386793750340

4916451936094420

30203642658706

201411032364438

869933317208876

6011354276117410

6011000000000004

5539878514522540

5424000000000015

4916759155933

3088000000000000

341019464477148

3566002020360500

378282246310005

4007000000027

4539475158333170

4539890911376230

5105105105105100

3096666928988980

343510064010360

374395534374782

4111111111111110

4242424242424242

4716976758661

4916491104658550

5268196752489640

5429800397359070

5472715456453270

5547392938355060

5556722757422205

6011000000000012

6011111111111117

6011601160116611

5500000000000004

Strict Tolerance (default)

All the same as Moderate Tolerance, with the addition of the following proximity keywords, with proximity value set to 10 terms:

account number

account ps

american express

americanexpress

amex

bank card

creditcard

credit card #

mastercard

bankcard

card num

card number

cc#

ccn

checkcard

credit card number

credit card#

mc

debit card

debitcard

diners club

dinersclub

discover

enroute

japanese card bureau

jcb

visa

Updated 2 years ago

Credit Card Number


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.