The Find & Replace transform allows you to find specific strings (words, phrases, or characters) within a text field and replace them with another string. You may also remove a specific string from a text field, by finding a substring and replacing it with nothing.
The Find & Replace transform can be particularly helpful to do things like replace the full names of a state with the abbreviation, like from Utah to UT, or remove a part of an ID that you don't want, for example, 123456789-01 to 123456789.
Using Find & Replace
To start using the Find & Replace transform you must select a text column from your data. As this transform only works with text data types, only the columns that are of the text data type will show in the Text Column dropdown selector.
If you need to use Find & Replace on a column that is not currently text, you will need to use the Data Type transform first.
After you've selected the column you would like to perform the Find & Replace transform on, you will need to select the Type of transformation you would like to perform.
Find & Replace Transform Types
Standard: Find and replace a string in a column with a new one.
This is the straightforward version of find and replace. Use it when you want to find a set string, and replace it with another string.
Once you select the standard transform type you will need to tell Grow what string you would like to Find and what string you would like to Replace it with.
Regex: Find and replace part of a string with a new string using regular expressions.
This version is more powerful but more advanced. It requires you to use regular expression syntax to help you find patterns within the column and replace it with a string. This is useful when you want to find many variations of a string to replace. For example, finding all words that start with the letter A.
Like the standard type, you will still add your inputs to the Find field, and the Replace field. However, in the Find field, you will add your regular expression to create the pattern you want to match. For more information on pattern matching in Postgres, see their documentation in their website.
There is one last field that appears for the Regex type, which is the Flags field. This is an optional field that can be used for Regex Find & Replace. More than one flag can be selected. See the table below for each of the flags, and their meanings.
Regular Expression Flags
Option | Description |
---|---|
b | rest of RE is a BRE |
c | case-sensitive matching (overrides operator type) |
e | rest of RE is an ERE |
i | case-insensitive matching |
m | historical synonym for n |
n | newline-sensitive matching |
p | partial newline-sensitive matching |
q | rest of RE is a literal (“quoted”) string, all ordinary characters |
s | non-newline-sensitive matching (default) |
t | tight syntax (default; see below) |
w | inverse partial newline-sensitive (“weird”) matching |
x | expanded syntax |