This is actually a very easy use case for KM, IF you know a little about RegEx.
KM makes Regular Expressions very easy to use. The challenge, of course, is coming up with the RegEx. But if you can't figure it out, you can always google it. Your use case is very common, and very old. I'm sure many have already developed the RegEx for it.
But it looks like @kcwhat has got you on the right track.
I'd just make two comments:
- I would NOT use KM Named Clipboards for this use case. The only time you really need a Named Clipboard is when you need to store rich text, images, or other objects. Named Clipboards are harder to use, and take up a lot more storage space on your Mac.
- If you happen to find a JavaScript RegEx solution, it almost always easier to use the KM native RegEx tools
Finally, this might be a good place to start:
Getting Started with Keyboard Maestro
- Read the Quick Start.
- This is essential to become familiar with KM terminology
- Do the tutorial (Help ➤ Tutorial) in the KM Editor.
- Gives you a live walkthrough of creating a macro in the KM Editor
- Review/Browse the Available Macro Actions
- For Help with an Action in your Macro, click on the gear icon
at the top right of the Action, and select "Help"
- Search the Keyboard Maestro Wiki for detailed help.
- Start small, and grow your macros organically.
- Be prepared for some trial and error in the beginning.
- Make good use of this Keyboard Maestro Forum
- Checkout these Great Resources
- Search for existing macros
- Post your questions/issues if you get stuck
- Be sure to first read: Tip: How Do I Get The Best Answer in the Shortest Time?
For more help, see Getting Started with Keyboard Maestro and the Forum .