Skip to main content

REGEX

Check how to use our REGEX generator to create personalized rules.

Updated over a year ago

REGEX is short for Regular Expressions. It's a powerful tool used to search, extract, and manipulate text based on patterns. Imagine you're looking for specific words in a giant book. REGEX would be like a magnifying glass that highlights only the words you want.

This is how Zapper can identify specific words in each rule added and notify you when one or more policies are violated.

How Does REGEX Work?

In REGEX, you define patterns you want to find in the text. For example, if you want to find all phone numbers, your pattern could be something like \d{3}-\d{4}, which means "three digits, followed by a hyphen, followed by four digits."

REGEX may seem intimidating at first, but with practice and patience, you'll start to feel more comfortable. It is a powerful tool for handling text efficiently.

When you acquire Zapper, we provide you with a REGEX Generator to help you create specific rules for your company's scenario:

image

Understanding the Interface

1. Text Area

In the center of the page, there is a text area where you can enter the text you want to apply your regular expression to—this is where you'll write the words that you want Zapper to identify within a single rule.

image

2. Add Condition

Adds a word to the REGEX code using the AND logic.

image

3. Remove Condition

Removes a word from the REGEX code using the AND logic.

image

4. Generated Regex

Below, you can see the Regex generated by the word(s) entered. This is the code that will be used by Zapper and should be pasted into the Rules area.

image

5. Test Your Regex Here

At the bottom of the page, you can write small texts to verify if the generated REGEX is correctly capturing the desired information before applying it in Zapper.

image

6. Save REGEX

By selecting this button, you can save the created code to the list on the right.

image

7. REGEX Spreadsheet

This is where the codes saved via the "Save REGEX" button will be listed.

image

8. Export CSV

You can export the saved codes in CSV format. This format is used to input a large number of rules at once into Zapper.

image

Creating a REGEX Code

Let’s take a simple example: imagine you want to find all mentions of the word troca in conversations with your employees.

The first step should be to enter the word into the text area.

image

Below, we can see that the code is working for the word troca and variants that have this prefix:

image

We can also see that the code is identifying phrases where the word "troca" or words with that prefix are used:

image

However, it’s important to note that this code does not identify words that are similar to "troca" but do not have the same prefix.

image

To achieve that, it's ideal to keep only the prefix "troc" as REGEX, as shown below:

image

Simple Rule


Here, you could create a simple rule, where only a single word and its variations will be identified. This type of REGEX is more effective for specific rules for particular situations in the company.

In the same code, using the OR logic, you can add more words by using commas.

OR Logic: Used when you want a match to occur if at least one of the criteria is met.

Here, in addition to the prefix "troc"—referring to "troca"—we can also add the prefix "receb"—referring to "receive".

ATTENTION: The words must be followed by commas, with no space between characters.

image

Advanced Rules

You can use this type of REGEX code to configure more complete rules, including related words. Some examples are inappropriate language, harassment, and others.

Another way to create codes that identify more than one term is through AND logic. For this option, we use the "Add Condition" button.

AND Logic: Used when you want a match to occur only if both criteria are met.

In this example, we will use the words "valor" and "especial".

image

Here, Zapper will only identify the message as an event if both words are used:

image


This type of REGEX code can be used for more complex rules, where two or more terms need to be present for an event to be considered valid. Some examples are bribery, sharing confidential information, and others.

Within these two formats, you can also change the type of match. Here’s how it works:

  • Broad Match: Suitable when you want to identify all instances of a term, even if it's part of words with different contexts and meanings.

    • Example: By defining the word "Sol," the broad match will also capture the words "solução," "absoluto," "consolar," among others, since all have the term "Sol" in their composition.

  • Exact Match: Important when you need to identify a specific word or phrase without including variations or contexts where the term appears as part of a larger word.

    • Example: When looking exactly for "test" in an exact match, words like "protesto," "testemunha," or "contestação" will not be identified.

  • Starting With: Useful when the beginning of the word is crucial for the desired context, avoiding words where the term appears in the middle or end.

    • Example: Searching for words that start with "port," the tool will capture "porta," "portão," among others, but will not capture words like "suporte" or "exportar."

  • Ending With: Essential when the end of the word (usually a suffix) is crucial for determining its meaning or context.

    • Example: A search for words ending in "correr" will capture "percorrer," "recorrer," but not include "corredor" or "correria."

Saving the rules list

After defining the desired rules, you can save them to the list by selecting the "Save REGEX" button.

image

Here, all REGEX generated during a single use of the REGEX Generator will be listed after selecting "Save REGEX."

In "Rule," you can define the name that this rule will have in Zapper.

image

By selecting "Export to CSV," a `.csv` file will be downloaded to your computer. This file can be viewed using spreadsheet software, like Microsoft Excel or Google Sheets.

image

Adding Rules to Zapper

After downloading, you need to open the spreadsheet and configure it in the correct format.

The spreadsheet must be configured as follows:

image

To apply this format to the `.csv` file generated by the REGEX Generator, follow these steps:

image

- In rule_name, enter the defined name for the rule.

- In rule_description, you can add a description of the rule. This is optional, so it can be left blank.

- In policy, add the policy to which the rule should belong.

- In rule, add the generated REGEX code.

The changes made must be saved, and the file should remain in `.csv` format.

To import the created rules, just select the "Import via CSV" option in the Policies and Rules tab in your Zapper dashboard:

image

Upon selecting "Import via CSV" and choosing the file, the following screen should appear:

image

By selecting "Confirm," the rules are added to Zapper and are ready for use.

Did this answer your question?