Introduction
As part of our Value Transforms functionality, we offer the ability to perform Regex Find and Replace.
Regex is short for Regular Expression, and we use it to search for formats, rather than actual values. This means you can search for a certain format, and replace it with something else. This is useful, for example, if you want to reformat date or telephone number values.
The Convertr platform supports PCRE Regex values. As this can be a tricky language to master, this document will also cover some commonly used examples.
Related documentation:
- Value Transforms
- Advanced Value Transforms/Manipulation: Trimming
- Advanced Value Transforms/Manipulation: Find and Replace
- Advanced Value Transforms/Manipulation: Regex Find and Replace
- Advanced Value Transforms/Manipulation: Concatenation
- Advanced Value Transforms/Manipulation: Casing
- Advanced Value Transforms/Manipulation: Hashing
- Advanced Value Transforms/Manipulation: Ordering
Best practice:
This document explains how to setup Value Tranforms at an Campaign level, however this method does not allow importing/copying of configurations across campaigns.
There is an option to setup Value Transforms at a Advertiser Level, where any configurations can then be imported into a campaign which removes repeated manual setup for any subsequent campaigns. Therefore, setting up Value Transforms at an Advertiser level is recommended.
Setup Process
1. Within a campaign, click the Admin menu and select Value Transforms.
2. Enable Value Transforms by using the toggle.
3. On this page, select Add.
4. Here, you'll need to fill out each field:
- Label: A name for the Value Transform
- Original Fieldname: the field you are looking to reformat
- New Fieldname: the field we will store your reformatted value in
- Order: This will dictate when this Value Transform should run, in relation to any other transformations set up in the campaign. By default this is 0, meaning that it will run first. Increasing the order changes when it will run.
5. You will need to select Manipulate. This will give you a type dropdown, where you can select Regex Find and Replace.
6. Enter your find and replace Regex, and click Add.
Your setup is complete from here! You'll be able to use the Preview at the bottom to check that it reformats as intended:
Common Regex Examples
Example | Find Regex | Replace Regex | Notes |
Change 2021-09-29 to 09/29/2021 | /(\d{4})-(\d{2})-(\d{2})/ | $2/$3/$1 | The Replace Regex can be amended, depending on your divider between the dates (e.g. $2.$3.$1 would give you 09.29.2021). |
Change 2021-09-29 to 29/09/2021 | /(\d{4})-(\d{2})-(\d{2})/ | $3/$2/$1 | The Replace Regex can be amended, depending on your divider between the dates (e.g. $3.$2.$1 would give you 29.09.2021). |
Change 2021-09-29 to 09/29/21 | /(\d{2})(\d{2})-(\d{2})-(\d{2})/ | $3/$4/$2 | The Replace Regex can be amended, depending on your divider between the dates (e.g. $3.$4.$2 would give you 09.29.21). |
Change 2021-09-29 to 29/09/21 | /(\d{2})(\d{2})-(\d{2})-(\d{2})/ | $4/$3/$2 | The Replace Regex can be amended, depending on your divider between the dates (e.g. $4.$3.$2 would give you 29.09.21). |
Change XXXXXXXXXX to XXX XXX XXXX | /(\d{3})(\d{3})(\d{4})/ | $1 $2 $3 | Useful for US telephone number formats |
Change XXXXXXXXXX to (XXX) XXX-XXXX | /(\d{3})(\d{3})(\d{4})/ | ($1) $2-$3 | Useful for US telephone number formats |
If field contains the word 'Manager', create a new field with value 'Management' | /(.*)(Manager)+(.*)/ | Management |
Useful for standardisation |
Create a new field with the word 'Example' | /^(.*)$/ | Example | The Find Regex is a catchall that can be used on any existing field and will capture the whole value. Useful for appending static data to lead automatically |
Concatenate the word 'example' BEFORE your field value | /^(.*)$/ | example $1 | Concatenation uses your field value as a start point. This allows you to set a value before that start point |
Remove line break | /(.*)(\n)(.*)/ | $1 $3 | Useful for 'textarea' field type where multiple lines are likely |