REGEXP_REPLACE

The REGEXP_REPLACE function replaces text using Google RE2 regular expressions.

In this article:

Sample Usage

REGEXP_REPLACE(Campaign , 'A_REALLY_LONG_NAME', 'ShortName')

Syntax

REGEXP_REPLACE(X, regular_expression, replacement)

 

Parameters:

  • X - a field or expression that includes a field.
  • regular_expression - a regular expression that matches a portion of field_expression.
  • replacement- the text with which to replace the matched portion of field_expression.

Notes

  • REGEXP_REPLACE uses RE2-style regular expressions.
  • The REGEXP_REPLACE function returns text values.

Examples

Replace a campaign code with a more readable name:

REGEXP_REPLACE(LOWER(Campaign), ".bc123", "Summer Sale")

This will replace codes like "abc123," "ABC123," "BBC123," etc. with "Summer Sale."

Was this helpful?
How can we improve it?