HomeDocumentation and Guides
Home

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:

201400000000009301755728361083088272824427380341132368578216353011133330000037144963539843138520000023237378282246310005
2100029563444123056930902590434000000000000947167338466199304539687075612974453939905059342222222222224024007116284
21490611004036786998927816707186990858160889460111111111111105555555555554444545578058606261052633867937503404916451936094420
3020364265870620141103236443886993331720887660113542761174106011000000000004553987851452254054240000000000154916759155933
308800000000000034101946447714835660020203605003782822463100054007000000027453947515833317045398909113762305105105105105100
309666692898898034351006401036037439553437478241111111111111104242424242424242471697675866149164911046585505268196752489640
54298003973590705472715456453270554739293835506055567227574222056011000000000012601111111111111760116011601166115500000000000004

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 numberaccount psamerican expressamericanexpressamexbank cardcreditcardcredit card #mastercard
bankcardcard numcard numbercc#ccncheckcardcredit card numbercredit card#mc
debit carddebitcarddiners clubdinersclubdiscoverenroutejapanese card bureaujcbvisa