I’m having some trouble with regex in Tableau. I tried the data in regexr.com with the data and there the following code works:
\[(.*?)\]
But when I try that one in Tableau I get null values. I use it as follows in Tableau:
REGEXP_EXTRACT([Notes],(‘ \[(.*?)\]’))
So I added the extra (‘ in front of the regex part and at the end ‘) but still end up with null values.
Any tips?
CodePudding user response:
You need to use
REGEXP_EXTRACT([Notes],'\[(.*?)]')
See the 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'