Notification

This article is about Looker Studio. For Looker documentation, visit https://cloud.google.com/looker/docs/intro.

Požadovaná stránka nie je momentálne k dispozícii vo vašom jazyku. V dolnej časti stránky si môžete vybrať iný jazyk alebo si môžete okamžite preložiť ľubovoľnú webovú stránku do požadovaného jazyka pomocou vstavanej funkcie prekladu v prehliadači Google Chrome.

REGEXP_MATCH

Returns true if the target value exactly matches the regular expression pattern.

Sample usage

REGEXP_MATCH(name, '[a-zA-Z].*')

Syntax

REGEXP_MATCH(X, regular_expression)

 

Parameters

  • X - a field or expression to evaluate.
  • regular_expression - a regular expression.

Returns

The REGEXP_MATCH function returns boolean values.

Notes

REGEXP_MATCH attempts to match the entire string contained in field_expression. For example, if field_expression is "ABC123":

REGEXP_MATCH(field_expression, 'A') returns false.
REGEXP_MATCH(field_expression, 'A.*') returns true.

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

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

Examples

Match if name begins with a letter:

REGEXP_MATCH(name, '[a-zA-Z].*')

Create arbitrary regions using CASE statements:

CASE
   WHEN REGEXP_MATCH
(country, "(USA|Canada|Mexico)") THEN "North America"
   WHEN REGEXP_MATCH(country, "(England|France)" ) THEN "Europe"
   ELSE "Other"
END

Use case-insensitive matching and logical operators:

CASE
  WHEN REGEXP_MATCH(Campaign, "((?i).*Recipes).*") 
    OR REGEXP_MATCH(Campaign, "((?i).*Cooking).*")
  THEN "Recipes"

  WHEN REGEXP_MATCH(Campaign, "((?i).*Grilling).*")
  THEN "Seasonal"

  WHEN REGEXP_MATCH(Campaign, "((?i).*Phone).*") 
    OR REGEXP_MATCH(Campaign, "((?i).*Tablet).*") 
    OR REGEXP_MATCH(Campaign, "((?i).*Console).*") 
    OR REGEXP_MATCH(Campaign, "((?i).*Laptop).*") 
    OR REGEXP_MATCH(Campaign, "((?i).*Wearable).*")
  THEN "Electronics" 

  ELSE "Other" 

END

Negative match using the NOT operator:

CASE 
   WHEN REGEXP_MATCH(dimension1, 'A') AND NOT REGEXP_MATCH(dimension1, 'B') 
   THEN 'C' 
   ELSE 'D' 
END

 

Pomohly vám tyto informace?

Jak bychom článek mohli vylepšit?
true
What's new in Looker Studio?

Learn about new features and recent changes. Looker Studio release notes live on Google Cloud.

Search
Clear search
Close search
Main menu
12249126813787875704
true
Prohledat Centrum nápovědy
true
true
true
true
true
102097
false
false