Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Regex to Parse City State

hellyars
13 - Pulsar

Regex question.  I have city and state in a single field.  The comma is NOT always present, so I can't use that as a delimiter. City names can be 1-2 part names. State names are always 2-3 uppercase characters.

How can I regex this.

 

I need to use a parse tool.  This regex expression does not work:  ^.*?[A-Z]+

 

 

Field1CityState
Larapinta, Brisbane, QLDLarapinta BrisbaneQLD
Blacktown Sydney NSWBlacktown SydneyNSW
Coomera QLDCoomeraQLD
Manly Vale NSWManly ValeNSW
Wingfield SAWingfieldSA
2 REPLIES 2
PhilipMannering
16 - Nebula
16 - Nebula

You could use,

 

 

(.*),? (\u+)

 

 

in the Regex Tool (Parse Method). I believe that will do the trick. 

PhilipMannering
16 - Nebula
16 - Nebula

Incidentally, your regex patter would have worked too if you add some parentheses and a $ sign.

^(.*?) ([A-Z]+)$

hen you Parse you always need to have a set of brackets to show what you're capturing. In the case above you're capturing everything up until a space and also capital letters at the end of your string. Don't forget to heed the case sensitivity checkbox.

Polls
We’re dying to get your help in determining what the new profile picture frame should be this Halloween. Cast your vote and help us haunt the Community with the best spooky character.
Don’t ghost us—pick your favorite now!
Labels