The Find & Replace transform allows a user 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 (essentially 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 (Utah to UT), or remove a part of an ID that you don't want (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'll 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'll need to select the "type" of transformation you'd 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. Used when you want to find a set string, and replace it with another string.
Once you select the standard transform type you'll 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 (Finding all words that start with the letter A).
Like the standard type, you'll still add your inputs to the Find field, and the Replace field, However, in the Find field, you'll add your regular expression to create the pattern you want to match. For more information on pattern matching in Postgres, see their documentation here.
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 forn |
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 |