REGEXP_EXTRACT

The REGEXP_EXTRACT function creates dimension values by extracting them from a source dimension using Google RE2 regular expressions.

In this article:

Sample Usage

REGEXP_EXTRACT(Campaign , 'TYPE:(.*)')

Syntax

REGEXP_EXTRACT(X, regular_expression)

 

Parameters:

  • X - a field or expression that includes a field.
  • regular_expression - a regular expression that extracts a portion of field_expression.

Notes

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

Examples

Extract the top-level directory in a URL

REGEXP_EXTRACT( URL , '^https://[^/]+/([^/]+)/' )

For example, if the URL field contained this page's address, the function above would return datastudio.

Was this helpful?
How can we improve it?