Parker, Douglas, Colorado
(which is city, county, state)
to
COLORADO, Douglas, Parker.
I have a bash script that will invert the "fields", and have created a macro where I select "Parker, Douglas, Colorado" in text and call Keyboard Maestro through a keystroke. This copies the string into a named clipboard, calls a bash script to invert the delimited string, and then pastes it back into the same location. However, I cannot figure out how to UPPERCASE just the first field (i.e. the part before the comma, as this could just as easily be NEW YORK, Oswego, Orwell). I suspect that if I were a smarter awk user, I might be able to do this in the script. But since I'm not such a smart awk user, I was hoping I could figure out a way for Keyboard Maestro to do this.
@danitaz:
Great solution. Shows how a simple RegEx can easily be used in KM. No script required.
I find RegEx to be one of the most useful languages to learn. Very powerful, lots of support, and can be used just about everywhere.
Regular expressions (RegEx or RegExp) are extremely powerful, but have an initial steep learning curve that is often intimidating. But once you get over that initial hump, and you continue to write new RegExp, it will become much easier.
I do all of my RegEx development at this free website:
I should have been more specific, because sometimes it's not just 3 fields. These are from census records. Sometimes they are even like "Area D, Tulsa, Tulsa City, Tulsa, Oklahoma, United States". I would want this to be "OKLAHOMA, Tulsa, Tulsa City, Tulsa, Area D" (i.e, I do a filter to remove United States or USA depending on the record). BUT Since I already have a macro that gets them into the proper order, using RegEx should get the first field capitalized.
OK, just having fun now with RegEx.
To show the power and simplicity of using RegEx in KM, here is a complete solution that both moves the last field to the first field, and makes it all upper case.
Example Output
Below is just an example written in response to your request. You will need to use as an example and/or change to meet your workflow automation needs.