Data Studio(Golang RE2):如何将字符串中每个单词的首字母大写

Data Studio (Golang RE2): how to capitalize first letter of each word in string

我正在直接连接到 Data Studio 中的数据源 (Google Analytics)。我正在使用文本字段“页面标题”字段。

我想添加一个计算字段,它将“页面标题”字段字符串中每个单词的首字母大写。

示例:

Current state Desired output
What to expect from the authorities in 2021 What To Expect From The Authorities In 2021
Sustainability – An emerging theme Sustainability – An Emerging Theme
Helping UK businesses make confident decisions Helping UK Businesses Make Confident Decisions

第一部分很简单。我可以使用

找到以小写字母开头的每个单词的第一个字母
(\b[a-z])

在旧的 PHP 中,我可以使用标记 \u 来替换为大写字母

\u

但是当我像这样在 Google Data Studio 中使用它时:

REGEXP_REPLACE(Page Title,"(\b[a-z])","\u")

我收到一个错误

Syntax error: Illegal escape sequence: \u must be followed by 4 hex digits but saw: \u).

根据我的研究,RE2 似乎不支持“\u”。但是我搜索了4.5小时,找不到用大写字母替换我的匹配项的东西。

非常感谢您的帮助。

根据 documentation.

,Data Studio 的正则表达式风格不支持

\U...\E