It is already two weeks ago since my last blog post. This two weeks I spent in Scotland. It is a very beautiful country with unforgettable landscaps. However, it is not the topic I want to talk about. In this blog I will continue the topic about the RegEx and its using in Tableau.
Tableau offers you four different uses cases of RegEx:
REGEXP_EXTRACT
If you have data like this: aspirin_20_mg_oral_tablet and you would like to extract onliy 20_mg.
What I do is I check my RegEx on this web site: http://regexr.com/
If it is ok, put this RegEx in Tableau function: REGEXP_EXTRACT([0-9][0-9]+[_]+[a-z]+) and extract all "20_mg"
REGEXP_EXTRACT_NTH
The same like the function before but here you can limit your extract to Nth index. Image you have data like this: aspirin_20565435 and you want to extract only "aspirin_20". So your formula should be: REGEXP_EXTRACT_NTH([a-z]+[0-9], 2)
REGEXP_MATCH
It is very easy one: Using REGEXP_MATCH we can find if the string the matches with entered pattern or not. If the string matches with the pattern it return true else false.
REGEXP_REPLACE
If you would like to replace somethin into something, then use this function.
Example: I want to replace all "aspirin_20_mg_oral_tablet" by space " ". My RegEx is:
REGEXP_REPLACE ([a-z0-9], ' ')
Here you can find more to RegEx:
Regular Expressions In Tableau
Best
Dilyana
Kommentare
Kommentar veröffentlichen