Replace
The Replace node is used to replace all instances of specified character, string, or substring within a string column with a new one. This is useful if the column contains formatting that is impractical for end-users and report-consumers. For instance, you may have a column of phone numbers where each sequence is separated by hyphen. You can replace the hyphen with a space to make it easier for end-users to read the results. Another example if the column contains strings that should be labeled differently. For instance, you might have a column containing food items with the word 'Donut'. Depending on your location, you may want to change the string 'on' to 'oughn' to switch to the British spelling of 'doughnut'
String Replacement
Start by connecting the Replace node to the Select node of the relevant table. Go to the Properties panel and select the columns for which you want to replace a string.
Search For: the character, string, or substring to search.
Replace With: the new character, string, or substring.
Search Options: use these options to make the search case sensitive, or to search for the exact string, rather than matching part of it.
Matching Type: the mechanism by which the search will be matched with results. The default is 'Normal', but you can switch to wildcards or regular expressions (see below).
Column Output: choose whether or not to keep the original column.
New Column Name: name the new column.
Matching Types
By default, the Matching type is set to Normal, but you can select the Wildcards option to use wildcards to replace single or multiple characters. For example:
Source |
Search |
Replace With |
Result |
---|---|---|---|
ZAAABCD |
A*BC |
R |
ZRD |
ZAXXBCD |
A*BC |
R |
ZRD |
ZAAABCD |
A?B |
R |
ZAARCD |
ZAAXBCD |
A?B |
R |
ZAARCD |
You can also use regex by selecting the Regular expressions option. For details about using regular expressions, click here.
In this example, the hyphens in the Phone column were replaced with spaces: