While i am solving the problems in the Tableau Community I see there are lot of Questions asked about how to extract numbers from a string
Consider we have a sample data like below
If we have static pattern then we can write LEFT and right calculations in tableau to extract the number but here the use case is different All the numeric letters were appearing in between or end of the string.
While doing the research i ended up using the two types of RegExp to extract a number from a string. One is REGEXP_REPLACE and Other would be REGEXP_EXTRACT.
Syntax:REGEXP_REPLACE(string, pattern, replacement)
Description: Returns a copy of the given string where the matching pattern is substituted with the replacement string.
Bring the data to tableau and write the below calculation
Pattern : [a-zA-Z]
[a-zA-Z] will match ASCII characters in the range from
Z and in the range from
Another way of achieving the same with different pattern using REGEXP_EXTRACT
Syntax: REGEXP_EXTRACT(String, Pattern)
Description : Returns the substring of the given string that matches the capturing group within the regular expression pattern. pattern requires one capturing group
Use the below calculation to extract numbers
Pattern : (\d+)
(start a capture group
\da shorthand character class, which matches all numbers; it is the same as
+one or more of the expression
)end a capture group
Hope this will helps
If you like this approach Plz share this blogspot.