How would I convert something like 'US (United States)' to just 'United States' ? Have to do this for multiple countries
Solved! Go to Solution.
Hi @pacbloyd could the row have more than one "string between parenthesis" occurence?
Hello @Thableaus - I don't think so. I just need to do this for many countries where there's an abbreviation before the full country name in parentheses.
What about a solution which simply trims off the first 4 characters (i.e. the 2 letter abbreviation, space, and opening parentheses, and then another formula to trim off the last character (i.e. the closing parentheses)?
I think I figured it out using a right and left function:
right([Country],Length([Country])-4)
left([Country],Length([Country])-1)
However, if there is a better formula, or a formula that extracts from parentheses, let me know
REGEX in tokenize mode to split only what you need:
Expression: \([^()]+\)
\( - open parenthesis
[^()]+ capture everything that is not an open/closing parenthesis
\) - closing parenthesis
I think that might work.
I'm sorry, if you don't wanna catch the parenthesis as well, you could use "unmarked groups".
(?:\()([^()]+)(?:\))
add ?: before open/closing parenthesis character.
The nice thing about using Tokenize that it's dynamic enough to grab multiple occurences.
That's for example if I had 3 instances of the same pattern. And if you want to make even more dynamic you could use Tokenize and Split to Rows, so you dont have to specify a number of columns.
Thank you, @binuacs !
Bonus question, how would I do the same, but for brackets instead of parentheses?
@pacbloyd the below RegEx formula remove both ( and [ from the country name
REGEX_Replace([Country], '(.+?)[\(\[](.+?)[\)\]]', '$2')