Syntax
REGEXP_REPLACE_ALL
Matches a pattern in the input string and replaces all matched portions with the specified replacement.Syntax
Parameters
| Parameter | Description | Supported input types |
|---|---|---|
<input> | The string to search for a matching pattern | TEXT |
<pattern> | An RE2 regular expression for matching with the string input. | TEXT |
<replacement> | The string to replace the matching pattern found in the input. This argument can include the following special sequences: * \& - To indicate that the substring matching the entire pattern should be inserted.* \n - Where n is a digit from 1 to 9, to indicate that the substring matching the n’th capturing group (parenthesized subexpression) of the pattern should be inserted. If pattern doesn’t have n capturing groups, the \n is ignored.* \\ - results in a single <br/>* \c - Specifies for any other character, c results in the same sequence \cNote, that for string literals the above escaping rules apply after string literals escaping rules for \. See examples below. | TEXT |
NULL, the return value is NULL.
Return Type
TEXT
Examples
Replace first occurrence of! with !!!:
| regexp_replace text |
|---|
| Hello, world!!! |
Rows: 1Execution time: 5.23ms
| regexp_replace_all text |
|---|
| Hello world ! |
Rows: 1Execution time: 5.17ms
| regexp_replace_all text |
|---|
| HHeelllloo,, WWoorrlldd!! |
Rows: 1Execution time: 5.53ms
| masked_email text |
|---|
| 1***@wa.gov |
| j***@gmail.com |
| m***@hotmail.com |
Rows: 3Execution time: 1.54ms
| converted_date text |
|---|
| 04/22/2000 |
| 07/25/2002 |
| 08/07/1970 |
| 11/11/2010 |
Rows: 4Execution time: 1.53ms