---
title: How to create a custom DLP policy with Regex?
description: Regular Expression (regex) is a string of characters that defines a search pattern. Regex can be specific keywords like 'bag' or complex patterns like credit card numbers:  \d{4}[-, ]?\d{4}[-, ]?\d{4}
---

[Skip to content](https://help.syscloud.com/how-to-create-a-custom-dlp-policy-with-regex#main-content)

English

Show submenu for translations

[Create Ticket](https://help.syscloud.com/kb-tickets/new?hsLang=en)

![Untitled design (1)-Aug-01-2022-12-37-27-80-PM.png\]](https://help.syscloud.com/hs-fs/hubfs/Untitled%20design%20(1)-Aug-01-2022-12-37-27-80-PM.png?height=40&name=Untitled%20design%20(1)-Aug-01-2022-12-37-27-80-PM.png)

- [Help Center](https://help.syscloud.com/)
- [Go to SysCloud](https://www.syscloud.com/)

Open main navigation

Close main navigation

- [Help Center](https://help.syscloud.com/)
- [Go to SysCloud](https://www.syscloud.com/)
- English
  
  Show submenu for translations
- [Create Ticket](https://help.syscloud.com/kb-tickets/new)

 Hello. How can we help you?

- There are no suggestions because the search field is empty.

1. [Help Center](https://help.syscloud.com/?hsLang=en)
2. [K-12 Security & Compliance](https://help.syscloud.com/k-12-security-compliance?hsLang=en)
3. [General](https://help.syscloud.com/k-12-security-compliance?hsLang=en#general)

# How to create a custom DLP policy with Regex?

Regular Expression (regex) is a string of characters that defines a search pattern. Regex can be specific keywords like 'bag' or complex patterns like credit card numbers: 

\\d{4}\[-, \]?\\d{4}\[-, \]?\\d{4}\[-, \]\\d{4} 

**Note**: SysCloud uses Perl Compatible Regular Expressions (PCRE).  

**Writing a regular expression:** 

The basic building blocks of regex are character classes, special characters and quantifiers. These characters are used to represent complex search patterns like credit card numbers, email addresses, customer IDs etc.. 

***1. Character classes:*** 

Character classes are used to match only a certain type of characters like digits, words or whitespaces. 

| **Symbol**  | **Description**  |
| --- | --- |
| \\s  | Match whitespace like space, tab etc.  |
| \\d  | Match digits like 0 - 9  |
| \\w  | Match word characters like A-Z, a-z, 0-9 and \_  |
| \\S  | Match any character which is not whitespace  |
| \\D  | Match any character which is not a digit  |
| \\W  | Match any character which is not a word character  |

 

***2. Special characters:*** 

Characters that are reserved for special use in regex. 

| **Symbol**  | **Description**  |
| --- | --- |
| \\  | Escapes, or remove the special meaning of the next character.    |
| ^  | Start of a string.  |
| \[^abc\]  | NOT to match any of the characters contained within the brackets  |
| $  | End of a string.  |
| .  | Match any character except newline  |
| \[\]  | Match a range of characters contained within the square brackets  For example – \[xyz\] searches for x or y or z  |
| \|  | Represents 'or' function  |
| ()  | Match everything enclosed in the parentheses  For example - (xyz) will match exactly xyz  |

 

***3. Quantifiers:*** 

Quantifiers tell the regex how many characters to search for. 

| **Symbol**  | **Description**  |
| --- | --- |
| \*  | 0 or more quantifier  |
| +  | 1 or more quantifier  |
| {  | start min/max quantifier  |
| }  | end min/max quantifier  |
| ?  | 0 or 1 quantifier  |

**Note**:   
In Perl Compatible Regular Expression, patterns should always be enclosed by delimiters like forward slashes (/), hash signs (#) and tildes (~). 

**Example** 

Below is an example of regex that searches for credit card numbers 

\\d{4}\[-, \]?\\d{4}\[-, \]?\\d{4}\[-, \]\\d{4} 

Let's break it down to understand the pattern, 

- \\d - search for digit 
- {4} - search for 4 characters 

So, **\\d{4}** - search for 4 digits 

- \[ \] - search for range of characters inside the square brackets 
- \[-, \] - search for either hypen, comma or space 
- ? - search for 0 or 1 occurance of the character preceeding 

So, **\[-, \]?** - search for one occurrence of either hypen, comma or space  

Combined, **\\d{4}\[-, \]?** - search for 4 digits and a hypen, comma or space. 

This is repeated thrice and then ends with a 4 digit, which would represent one of three formats given below, 

1. 4444-4444-4444-4444
2. 4444,4444,4444,4444
3. 4444 4444 4444 4444

[Here's](https://regex101.com/) an online tool to help you build your regex. This website has an explanation of the regex you build, detailed match information and quick reference guides. Please do not forget to select PCRE or PCRE2 in the flavors on the left-hand pane. 

**Additional resources: ** 

[https://perldoc.perl.org/perlre](https://perldoc.perl.org/perlre) 

[https://www.debuggex.com/cheatsheet/regex/pcre](https://www.debuggex.com/cheatsheet/regex/pcre) 

[https://www.php.net/manual/en/regexp.introduction.php](https://www.php.net/manual/en/regexp.introduction.php) 

**Sources:** 

[https://www.php.net/manual/en/regexp.introduction.php](https://www.php.net/manual/en/regexp.introduction.php) 

[https://qualysguard.qg2.apps.qualys.com/qwebhelp/fo\_portal/module\_pc/policies/regular\_expression\_symbols.htm#:~:text=Use%20a%20hyphen%20(%2D)%20for,most%20characters%20are%20interpreted%20literally.&text=Match%20any%20single%20character%20except,%5B%5E0%2D9%5D.&text=Group%20one%20or%20more%20regular,consisting%20of%20sub%2Dregular%20expressions](https://qualysguard.qg2.apps.qualys.com/qwebhelp/fo_portal/module_pc/policies/regular_expression_symbols.htm#:~:text=Use%20a%20hyphen%20(%2D)%20for,most%20characters%20are%20interpreted%20literally.&text=Match%20any%20single%20character%20except,%5B%5E0%2D9%5D.&text=Group%20one%20or%20more%20regular,consisting%20of%20sub%2Dregular%20expressions). 

- [Get started with Turbo backup](https://help.syscloud.com/get-started-with-turbo-backup?hsLang=en#main-content)

    - [General](https://help.syscloud.com/get-started-with-turbo-backup?hsLang=en#general)
    - [Account creation](https://help.syscloud.com/get-started-with-turbo-backup?hsLang=en#account-creation)
    - [Create and configure backup jobs](https://help.syscloud.com/get-started-with-turbo-backup?hsLang=en#create-and-configure-backup-jobs)
    - [Connect clouds](https://help.syscloud.com/get-started-with-turbo-backup?hsLang=en#connect-clouds)
    - [Configure backup](https://help.syscloud.com/get-started-with-turbo-backup?hsLang=en#configure-backup)
    - [Manage archives](https://help.syscloud.com/get-started-with-turbo-backup?hsLang=en#manage-archives)
    - [Cloud Connection](https://help.syscloud.com/get-started-with-turbo-backup?hsLang=en#cloud-connection)
    - [Notification Center](https://help.syscloud.com/get-started-with-turbo-backup?hsLang=en#notification-center)
    - [Settings](https://help.syscloud.com/get-started-with-turbo-backup?hsLang=en#settings)
- [Manage Legacy backup](https://help.syscloud.com/manage-legacy-backup?hsLang=en#main-content)

    - [General](https://help.syscloud.com/manage-legacy-backup?hsLang=en#general)
    - [SysCloud application](https://help.syscloud.com/manage-legacy-backup?hsLang=en#syscloud-application)
    - [Backup archives](https://help.syscloud.com/manage-legacy-backup?hsLang=en#backup-archives)
    - [Error messages](https://help.syscloud.com/manage-legacy-backup?hsLang=en#error-messages)
- [Google Workspace](https://help.syscloud.com/google-workspace?hsLang=en#main-content)

    - [Setup Google Workspace backup](https://help.syscloud.com/google-workspace?hsLang=en#setup-google-workspace-backup)
    - [Google Admin Console](https://help.syscloud.com/google-workspace?hsLang=en#google-admin-console)
    - [Google Chat](https://help.syscloud.com/google-workspace?hsLang=en#google-chat)
    - [Backup archives](https://help.syscloud.com/google-workspace?hsLang=en#backup-archives)
    - [Restore](https://help.syscloud.com/google-workspace?hsLang=en#restore)
    - [Export](https://help.syscloud.com/google-workspace?hsLang=en#export)
    - [Errors](https://help.syscloud.com/google-workspace?hsLang=en#errors)
    - [Sync](https://help.syscloud.com/google-workspace?hsLang=en#sync)
    - [Cloud connection](https://help.syscloud.com/google-workspace?hsLang=en#cloud-connection)
- [Google Classroom](https://help.syscloud.com/google-classroom?hsLang=en#main-content)

    - [Setup Google Classroom backup](https://help.syscloud.com/google-classroom?hsLang=en#setup-google-classroom-backup)
    - [Backup archives](https://help.syscloud.com/google-classroom?hsLang=en#backup-archives)
    - [Restore](https://help.syscloud.com/google-classroom?hsLang=en#restore)
    - [Export](https://help.syscloud.com/google-classroom?hsLang=en#export)
- [Microsoft 365](https://help.syscloud.com/microsoft-365?hsLang=en#main-content)

    - [Setup Microsoft 365 backup](https://help.syscloud.com/microsoft-365?hsLang=en#setup-microsoft-365-backup)
    - [Backup archives](https://help.syscloud.com/microsoft-365?hsLang=en#backup-archives)
    - [Restore](https://help.syscloud.com/microsoft-365?hsLang=en#restore)
    - [Export](https://help.syscloud.com/microsoft-365?hsLang=en#export)
    - [Errors](https://help.syscloud.com/microsoft-365?hsLang=en#errors)
    - [Sync](https://help.syscloud.com/microsoft-365?hsLang=en#sync)
- [Slack](https://help.syscloud.com/slack?hsLang=en#main-content)

    - [Setup Slack backup](https://help.syscloud.com/slack?hsLang=en#setup-slack-backup)
    - [Slack Backup archives](https://help.syscloud.com/slack?hsLang=en#slack-backup-archives)
    - [Restore Slack data](https://help.syscloud.com/slack?hsLang=en#restore-slack-data)
    - [Export Slack data](https://help.syscloud.com/slack?hsLang=en#export-slack-data)
    - [Resolve Slack errors](https://help.syscloud.com/slack?hsLang=en#resolve-slack-errors)
- [QuickBooks Online](https://help.syscloud.com/quickbooks-online?hsLang=en#main-content)

    - [Setup QuickBooks Online backup](https://help.syscloud.com/quickbooks-online?hsLang=en#setup-quickbooks-online-backup)
    - [Backup archives](https://help.syscloud.com/quickbooks-online?hsLang=en#backup-archives)
    - [Restore](https://help.syscloud.com/quickbooks-online?hsLang=en#restore)
    - [Export](https://help.syscloud.com/quickbooks-online?hsLang=en#export)
- [Xero](https://help.syscloud.com/xero?hsLang=en#main-content)

    - [Backup archives](https://help.syscloud.com/xero?hsLang=en#backup-archives)
    - [Export](https://help.syscloud.com/xero?hsLang=en#export)
    - [Setup Xero backup](https://help.syscloud.com/xero?hsLang=en#setup-xero-backup)
- [HubSpot](https://help.syscloud.com/hubspot?hsLang=en#main-content)

    - [Setup HubSpot backup](https://help.syscloud.com/hubspot?hsLang=en#setup-hubspot-backup)
    - [Backup archives](https://help.syscloud.com/hubspot?hsLang=en#backup-archives)
    - [Restore](https://help.syscloud.com/hubspot?hsLang=en#restore)
    - [Export](https://help.syscloud.com/hubspot?hsLang=en#export)
    - [Errors](https://help.syscloud.com/hubspot?hsLang=en#errors)
- [Salesforce](https://help.syscloud.com/salesforce?hsLang=en#main-content)

    - [Setup Salesforce backup](https://help.syscloud.com/salesforce?hsLang=en#setup-salesforce-backup)
    - [Backup archives](https://help.syscloud.com/salesforce?hsLang=en#backup-archives)
    - [Restore](https://help.syscloud.com/salesforce?hsLang=en#restore)
    - [Export](https://help.syscloud.com/salesforce?hsLang=en#export)
    - [Errors](https://help.syscloud.com/salesforce?hsLang=en#errors)
- [Box](https://help.syscloud.com/box?hsLang=en#main-content)

    - [Setup backup](https://help.syscloud.com/box?hsLang=en#setup-backup)
    - [Restore Box Data](https://help.syscloud.com/box?hsLang=en#restore-box-data)
    - [Resolve errors](https://help.syscloud.com/box?hsLang=en#resolve-errors)
    - [Export](https://help.syscloud.com/box?hsLang=en#export)
- [Sky - AI Copilot](https://help.syscloud.com/sky-ai-copilot?hsLang=en)
- [Add-ons](https://help.syscloud.com/add-ons?hsLang=en#main-content)

    - [Turbo backup](https://help.syscloud.com/add-ons?hsLang=en#turbo-backup)
    - [Advanced ransomware recovery](https://help.syscloud.com/add-ons?hsLang=en#advanced-ransomware-recovery)
    - [Archiver](https://help.syscloud.com/add-ons?hsLang=en#archiver)
    - [Data change insights](https://help.syscloud.com/add-ons?hsLang=en#data-change-insights)
    - [Security & Compliance](https://help.syscloud.com/add-ons?hsLang=en#security-compliance)
    - [eDiscovery](https://help.syscloud.com/add-ons?hsLang=en#ediscovery)
    - [Ransomware](https://help.syscloud.com/add-ons?hsLang=en#ransomware)
    - [Resolve errors](https://help.syscloud.com/add-ons?hsLang=en#resolve-errors)
- [Partner Portal](https://help.syscloud.com/partner-portal?hsLang=en#main-content)

    - [Automated onboarding](https://help.syscloud.com/partner-portal?hsLang=en#automated-onboarding)
- [Subscription and payments](https://help.syscloud.com/subscription-and-payments?hsLang=en#main-content)

    - [Manage subscription (Turbo backup)](https://help.syscloud.com/subscription-and-payments?hsLang=en#manage-subscription-turbo-backup)
    - [Manage subscription (Legacy backup)](https://help.syscloud.com/subscription-and-payments?hsLang=en#manage-subscription-legacy-backup)
    - [Manage Licenses (Turbo backup)](https://help.syscloud.com/subscription-and-payments?hsLang=en#manage-licenses-turbo-backup)
    - [Manage Licenses (Legacy backup)](https://help.syscloud.com/subscription-and-payments?hsLang=en#manage-licenses-legacy-backup)
    - [Billing FAQs](https://help.syscloud.com/subscription-and-payments?hsLang=en#billing-faqs)
    - [US sales tax FAQs](https://help.syscloud.com/subscription-and-payments?hsLang=en#us-sales-tax-faqs)
- [Manage admin roles](https://help.syscloud.com/manage-admin-roles?hsLang=en#main-content)

    - [Admin roles (Turbo backup)](https://help.syscloud.com/manage-admin-roles?hsLang=en#admin-roles-turbo-backup)
- [Settings](https://help.syscloud.com/settings?hsLang=en#main-content)

    - [Security](https://help.syscloud.com/settings?hsLang=en#security)
    - [Manage account](https://help.syscloud.com/settings?hsLang=en#manage-account)
    - [Manage users](https://help.syscloud.com/settings?hsLang=en#manage-users)
    - [Manage domains](https://help.syscloud.com/settings?hsLang=en#manage-domains)
    - [Backup](https://help.syscloud.com/settings?hsLang=en#backup)
- [K-12 Security & Compliance](https://help.syscloud.com/k-12-security-compliance?hsLang=en#main-content)

    - [General](https://help.syscloud.com/k-12-security-compliance?hsLang=en#general)
    - [Google Workspace security and compliance](https://help.syscloud.com/k-12-security-compliance?hsLang=en#google-workspace-security-and-compliance)
    - [Microsoft 365 security and compliance](https://help.syscloud.com/k-12-security-compliance?hsLang=en#microsoft-365-security-and-compliance)
- [Google Drive Encryption](https://help.syscloud.com/google-drive-encryption?hsLang=en)
- [Uncategorized](https://help.syscloud.com/uncategorized?hsLang=en)
- [Shopify](https://help.syscloud.com/shopify?hsLang=en#main-content)

    - [Setup backup](https://help.syscloud.com/shopify?hsLang=en#setup-backup)
    - [Restore](https://help.syscloud.com/shopify?hsLang=en#restore)
    - [Export](https://help.syscloud.com/shopify?hsLang=en#export)
- [Ransomware](https://help.syscloud.com/ransomware?hsLang=en)
- [Cookie consent](https://help.syscloud.com/cookie-consent?hsLang=en)
- [Google Admin Console](https://help.syscloud.com/google-admin-console?hsLang=en)
- [Microsoft O365](https://help.syscloud.com/microsoft-o365?hsLang=en#main-content)

    - [Restore](https://help.syscloud.com/microsoft-o365?hsLang=en#restore)
    - [Export](https://help.syscloud.com/microsoft-o365?hsLang=en#export)
    - [Backup Archives](https://help.syscloud.com/microsoft-o365?hsLang=en#backup-archives)

- [Go to SysCloud](https://www.syscloud.com/)
- [Create Ticket](https://www.syscloud.com/support/ticket/)

[![Chill listening crop-3](https://help.syscloud.com/hs-fs/hubfs/Syscloud%20logo@2x-100.jpg?width=116&height=24&name=Syscloud%20logo@2x-100.jpg "Chill listening crop-3")](https://www.syscloud.com/)

SysCloud Help Center

Copyright © 2025, SysCloud Inc.