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]+
| Field1 | City | State |
| Larapinta, Brisbane, QLD | Larapinta Brisbane | QLD |
| Blacktown Sydney NSW | Blacktown Sydney | NSW |
| Coomera QLD | Coomera | QLD |
| Manly Vale NSW | Manly Vale | NSW |
| Wingfield SA | Wingfield | SA |
Solved! Go to Solution.
You could use,
(.*),? (\u+)
in the Regex Tool (Parse Method). I believe that will do the trick.
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.
