How Do I Extract Address Fields from a String on the Clipboard?


Thank you for the help in advance, I did a quick search but not even sure what to search for.

I am looking to break a clipboards text into three sections. The clipboard will always have City, State, Zip an example is:

Lake Orion, Michigan 48359-1160

I would like it to separate Lake Orion to a City Clipboard, Michigian to a state clipboard and the Zip to a zip code clipboard so that I can pull that information at a later time. Thank you.

Easy using Regex:

in a KM Search using Regular Expression action.

Copy your location data to the clipboard, and use this Search Action:

Search using Regular Expression.kmactions (655 B)
Before importing this KM Action, Open KM Editor to the Macro of interest, and click on the Action PRIOR to where you want this action.

BTW, there is no benefit to using KM Named Clipboards for plain text data.
Global Variables are much better.


This works perfectly thank you very much. Now to learn how and why it works.

You can use to view, develop, and understand Regular Expressions.
Highly recommended.

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:

You may also find these sites helpful:
Regular Expressions Quick Start
Regular Expressions -- KM Wiki
Quick-Start: Regex Cheat Sheet

Hello and thanks again for the assistance. I am noticing it does not work on many addresses because some States have two words suck as North Dakota. Is there a resolution to that ? I again truly appreciate any and all help.

Yep. Sorry, I should have planned for that.
Use this RegEx:
(.+),\h+([\p{L} ]+)\h+([\d-]+)

For details, see

The [\p{L} ] allows for either letters or spaces to be in that capture group.

Please let us know if this works for you.

Works perfectly. Thank you so much.