-1

I have a list of data in tableau with different total string count and different suffixes for example:

  1. SAO JOSE DO RIO PRETO 1
  2. SAO JOSE DO RIO PRETO 2
  3. SAN LUIS 1
  4. BELO HORIZONTE 3
  5. RIO DE JANEIRO EDU
  6. GOIANIA (Jc-01)
  7. RIO DE JANEIRO (JE-09)
  8. RIO DE JANEIRO 1 (CFMG)

In tableau 2020.2.6 ... REGEXP_EXTRACT(string, "^([A-Z]+ )*[A-Z]+") does not work.

Thank you in advance for your tips.

sycythe_j
  • 1
  • 1

1 Answers1

-1

the following regular expression will match the city names

^(?:[A-Z][a-z]+ )*[A-Z][a-z]+

use it with REGEXP_EXTRACT(string, "^(?:[A-Z][a-z]+ )*[A-Z][a-z]+")

Abdessabour Mtk
  • 3,677
  • 2
  • 9
  • 21
  • Hello, @AbdessabourMtK ... I am using this REGEXP_EXTRACT([string], '([A-Z]+ )*[A-Z]+'), since the city are in all CAP's. My apologies for omission. For one word cities i get "null and for multi word cities it grabs the second word in the string. – sycythe_j Nov 20 '20 at 14:16
  • @sycythe_j can you update the question with accurate examples, also the null and the selecting of the second word is due to the way `REGEXP_EXTRACT` work. I'll look into the documentation and try to come up with a solution. – Abdessabour Mtk Nov 20 '20 at 15:09
  • @sycythe_j try the new answer. – Abdessabour Mtk Nov 20 '20 at 15:57