Replace All
Overview
The replace all transform works like the replace transform, except that it can perform multiple replace operations on the incoming data instead of just one pattern. Use the replace all transform to find multiple patterns of characters within incoming data and replace all instances of those patterns with alternate values. The transform recognizes standard regex syntax. See the References section for more information about regex.
Transform structure
The replace transform takes a table attribute of key-value pairs as an argument. Each pair identifies the pattern to search for as its key and the replacement string as its value. The transform also requires the standard type and name attributes:
{
"attributes": {
"table": {
"-": " ",
"\"": "'",
"ñ": "n"
}
},
"type": "replaceAll",
"name": "Replace All Transform"
}
Top-level properties (required)
-
type
string(required)
Must be set toreplaceAll. -
name
string(required)
The name of the transform as it will appear in the UI's dropdown menus. -
requiresPeriodicRefresh
boolean(optional)
Whether the transform logic should be reevaluated every evening as part of the identity refresh process. Default isfalse.
Attributes
The replace all transform uses the following structure:
{
"type": "replaceAll",
"name": "Transform Name",
"attributes": {
"table": {
"pattern1": "replacement1",
"pattern2": "replacement2"
}
}
}
attributes (required)
The attributes object contains the replacement table configuration.
Required
- table
object(required)
A JSON object of key-value pairs. Each pair identifies the pattern to search for (key) and the replacement string (value). Supports standard regex syntax.
Optional
- input
object(optional)
Explicitly defines the input data passed into the transform. If not provided, the transform uses input from the source and attribute combination configured in the UI.
Examples
This transform makes a simple set of special character replacements, exchanging a space for a hyphen and removing the Spanish tilde from the "n."
Input: "Enrique Jose-Piñon"
Output: "Enrique Jose Pinon"
Transform request body:
{
"attributes": {
"table": {
".": "-",
"\"": "'",
"ñ": "n"
}
},
"type": "replaceAll",
"name": "Replace All Transform"
}
This example uses more complex regex patterns to remove any alphabet characters from the input string and replace periods with hyphens.
Input: "ad512.777.1234"
Output: "512-777-1234"
Transform request body:
{
"attributes": {
"input": "",
"table": {
"[.]": "-",
"[a-zA-z]": ""
}
},
"type": "replaceAll",
"name": "Replace All Transform"
}