Tableau 使用正则表达式给出 NULL 值

Tableau gives NULL Value with Regex

我在 Tableau 中使用正则表达式时遇到了一些问题。我用数据尝试了 regexr.com 中的数据,下面的代码有效:

\[(.*?)\] 

enter image description here

但是当我在 Tableau 中尝试那个时,我得到了空值。我在 Tableau 中按如下方式使用它:

REGEXP_EXTRACT([Notes],(‘ \[(.*?)\]’))

所以我添加了额外的('在正则表达式部分的前面和末尾')但仍然以空值结束。

有什么建议吗?

您需要使用

REGEXP_EXTRACT([Notes],'\[(.*?)]')

REGEXP_EXTRACT help

REGEXP_EXTRACT(string, pattern)
Returns the portion of the string that matches the regular expression pattern. This function is available for Text File, Hadoop Hive, Google BigQuery, PostgreSQL, Tableau Data Extract, Microsoft Excel, Salesforce, Vertica, Pivotal Greenplum, Teradata (version 14.1 and above), Snowflake, and Oracle data sources.

For Tableau data extracts, the pattern must be a constant.

For information on regular expression syntax, see your data source's documentation. For Tableau extracts, regular expression syntax conforms to the standards of the ICU (International Components for Unicode), an open source project of mature C/C++ and Java libraries for Unicode support, software internationalization, and software globalization. See the Regular Expressions(Link opens in a new window) page in the online ICU User Guide.

Example

REGEXP_EXTRACT('abc 123', '[a-z]+\s+(\d+)') = '123'