Garrett Berg
Garrett Berg

Reputation: 63

REGEX_EXTRACT in Data Studio not matching Regex pattern

I am using REGEX pattern -\\s.+?_{1} To match FY22_1-103_Evergreen - US Territories (US Virgin Islands)_ Quitters_Video Views_Twitter Feed_07.01.21-09.15.21

But the results are null in the table the regex function is returning to. I'm not sure if I just don't fully understand the limitations of re2, or if I am missing something else.

EDIT:

I ended up trying a raw string R"(-\s.+?_{1})" which worked.

Upvotes: 2

Views: 286

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 627607

You can use a regex with a capturing group like

-\s+([^_]+)_

See the regex demo.

Details:

  • - - a hyphen
  • \s+ - one or more whitespaces
  • ([^_]+) - Capturing group 1: one or more chars other than an underscore
  • _ - an underscore.

Upvotes: 1

Related Questions