RegEx and Query Examples for PII Detection

Article: 100050109
Last Published: 2018-04-10
Ratings: 1 0
Product(s): Veritas Alta SaaS Protection

Description

MasterCard

To find MasterCard numbers without spaces (e.g. 5500000000000004), use:

RegEx Type: Single Term Regexp

5[1-5][0-9]{14}

To find MasterCard numbers that might have spaces or dashes (e.g. 5500 0000 0000 0004), use:

RegEx Type:  Advanced ElasticSearch Query

{
    "span_near": {
      "clauses": [
        { "span_multi": { "match" : { "regexp": { "blob.content": "5[1-5][0-9]{2}" } } } },
        { "span_multi": { "match" : { "regexp": { "blob.content": "[0-9]{4}" } } } },
        { "span_multi": { "match" : { "regexp": { "blob.content": "[0-9]{4}" } } } },
        { "span_multi": { "match" : { "regexp": { "blob.content": "[0-9]{4}" } } } }
        ],
     "slop": 0,
      "in_order": true
    }
}

Visa

To find Visa numbers without spaces (e.g. 4111111111111111), use:

RegEx Type: Single Term Regexp

4[0-9]{15}

To find Visa numbers that might have spaces or dashes (e.g. 4111-1111-1111-1111), use:

RegEx Type:  Advanced ElasticSearch Query

{
    "span_near": {
      "clauses": [
        { "span_multi": { "match" : { "regexp": { "blob.content": "4[0-9]{3}" } } } },
        { "span_multi": { "match" : { "regexp": { "blob.content": "[0-9]{4}" } } } },
        { "span_multi": { "match" : { "regexp": { "blob.content": "[0-9]{4}" } } } },
        { "span_multi": { "match" : { "regexp": { "blob.content": "[0-9]{4}" } } } }
        ],
      "slop": 0,
      "in_order": true
    }
}

American Express

To find American Express numbers without spaces (e.g. 340000000000009), use:

RegEx Type: Single Term Regexp

3[47][0-9]{13}

To find American Express numbers that might have spaces or dashes (e.g. 3400 0000 0000 009), use:

RegEx Type:  Advanced ElasticSearch Query

{
    "span_near": {
      "clauses": [
        { "span_multi": { "match" : { "regexp": { "blob.content": "3[47][0-9]{2}" } } } },
        { "span_multi": { "match" : { "regexp": { "blob.content": "[0-9]{6}" } } } },
        { "span_multi": { "match" : { "regexp": { "blob.content": "[0-9]{5}" } } } }
        ],
     "slop": 0,
      "in_order": true
    }
}

Social Security Number

To find SSNs, use:

RegEx Type:  Advanced ElasticSearch Query

{
    "span_near": {
      "clauses": [
        { "span_multi": { "match" : { "regexp": { "blob.content": "[0-9]{3}" } } } },
        { "span_multi": { "match" : { "regexp": { "blob.content": "[0-9]{2}" } } } },
        { "span_multi": { "match" : { "regexp": { "blob.content": "[0-9]{4}" } } } }
        ],
      "slop": 0,
      "in_order": true
    }
}

IP Address

To find IP addresses, use:

RegEx Type:  Single Term Regexp

[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}

Was this content helpful?