Detect credit card numbers in an email

Updated 3 years ago by admin

If you want to detect when an email contains something that looks like a credit card number, you'll need to set up a new Rule as follows.

  1. Visit your USS Dashboard and click ProductsE-mail SecurityCustom Rule Data.
  2. Click to create a new Rule RegEx.
  3. Give it a sensible name such as Credit Card numbers and click .
  4. Left-click your new Rule to edit it.
  5. In the value field, enter
\b4\d{3}([\ \-]?)\d{4}\1\d{4}\1\d{4}\b(?!([^<]+)?>)
  1. Click .
  2. Switch to the Message Rules tab.
  3. Create a new Rule called Credit Cards.
  4. Add a Body or Subject Condition, with the value set to Matches: Credit Card numbers.
  5. Add your desired Action or Final Action, and click .

Custom Rule Data for other credit card types

The example given above will detect Visa cards. The following RegEx patterns can be used to detect other credit card types. You'll need to create a new Custom Rule Data for each one.

\b5[1-5]\d{2}([\ \-]?)\d{4}\1\d{4}\1\d{4}\b(?!([^<]+)?>)
Discover or Diners
\b6(?:011|22(?:1(?=[\ \-]?(?:2[6-9]|[3-9]))|[2-8]|9(?=[\ \-]?(?:[01]|2[0-5])))|4[4-9]\d|5\d\d)([\ \-]?)\d{4}\1\d{4}\1\d{4}\b(?!([^<]+)?>)
JCB (China)
\b35(?:2[89]|[3-8]\d)([\ \-]?)\d{4}\1\d{4}\1\d{4}\b(?!([^<]+)?>)
American Express
\b(?<!\-|\.)3[47]\d\d([\ \-]?)(?<!\d\ \d{4}\ )(?!(\d)\2{5}|123456|234567|345678)\d{6}(?!\ \d{5}\ \d)\1(?!(\d)\3{4}|12345|56789)\d{5}(?!\-)(?!\.\d)\b(?!([^<]+)?>)

How did we do?