Looker Studio is now called Data Studio. Learn more about this change.

REGEXP_EXTRACT

Returns the first matching substring in the target value which matches the regular expression pattern.

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 X. regular_expression must contain a valid extraction pattern.

Returns

The REGEXP_EXTRACT function returns Text data type values.

Example

Example formula Input Output
REGEXP_EXTRACT( URL, '\^https://\[\^/\]+/(\[\^/\]+)/' ) https://support.google.com/looker-studio/answer/7050487 looker-studio
REGEXP_EXTRACT( URL, '\^https://\[\^/\]+/(\[\^/\]+)/' ) https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators bigquery

Notes

Data Studio uses the RE2 expression syntax. For more details, see Regular Expressions in Data Studio.

Note that patterns containing escape characters such as \ may require additional escaping in Data Studio, which can be avoided with the use of raw string literals.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026年08月26日 UTC.