Text Expansion with RegEx [Example]

Use Case

Provide a text expansion (typed string) macro that handles the following:

  1. Starts on a word boundary
  2. Uses the punctuation that was typed
  3. Case of Output Replacement String is set based on Case of Typed String
    So, the output could be any of these:
    • anybody
    • Anybody
    • ANYBODY
  • plus the typed punctuation.

MACRO:   Text Expansion with RegEx [Example]

~~~ VER: 2.0    2019-05-17 ~~~

DOWNLOAD:

Text Expansion with RegEx [Example].kmmacros (14 KB)
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.


This macro was built in response to:

Typed String Typing Speed - Faster?


ReleaseNotes

Author.@JMichaelTX

PURPOSE:

  • Example of Text Expansion that Handles Case and Punctuation

HOW TO USE

  1. First, make sure you have followed instructions in the Macro Setup below.
  2. Macro is triggered by Typed String
    • Start a new word that uses the typed text of "anb" (any case) and ends with a Space, Period, Comma, or Question Mark.
    • IF all text is all CAPS, then the output will be all upper case
    • IF only the first character is CAPS, then the output will be with only the first character in uppder case.

MACRO SETUP

  • Carefully review the Release Notes and the Macro Actions
    • Make sure you understand what the Macro will do.
    • You are responsible for running the Macro, not me. ??
      .
  1. Assign a Trigger to this maro.
  2. Move this macro to a Macro Group that is only Active when you need this Macro.
  3. ENABLE this Macro.
    .
  • REVIEW/CHANGE THE FOLLOWING MACRO ACTIONS:
    (all shown in the magenta color)
    • Set to the word or string to be output
      • Should be all lower case, no punctuation

REQUIRES:

  1. KM 8.2+
  2. macOS 10.11.6 (El Capitan)

TAGS: @TypedString @TextExpansion @RegEx

USER SETTINGS:

  • Any Action in magenta color is designed to be changed by end-user

ACTION COLOR CODES

  • To facilitate the reading, customizing, and maintenance of this macro,
    key Actions are colored as follows:
  • GREEN -- Key Comments designed to highlight main sections of macro
  • MAGENTA -- Actions designed to be customized by user
  • YELLOW -- Primary Actions (usually the main purpose of the macro)
  • ORANGE -- Actions that permanently destroy Variables or Clipboards,
    OR IF/THEN and PAUSE Actions

USE AT YOUR OWN RISK

  • While I have given this a modest amout of testing, and to the best of my knowledge will do no harm, I cannot guarantee it.
  • If you have any doubts or questions:
    • Ask first
    • Turn on the KM Debugger from the KM Status Menu, and step through the macro, making sure you understand what it is doing with each Action.

2 Likes

Whoa. That's pretty cool lol. I do have a couple of questions:

1. This is my first macro I've downloaded from the forum, and at first, when I imported it to my KM editor (and tested it), the action colours didn't transfer? I'm on MacOS High Sierra 10.13.6, KM Version 8.2.4. Each action was frozen on blue even though it showed, when I click the gear icon, that it is set to, in this example, magenta:

image

After about 10 minutes, the colours do now show (I process information via colours, so that makes me happy lol), but I was just curious as to why it did that.

2. I was concerned about the speed at which the macro would execute with all these additional actions, but it seems to execute with the same speed as regular insert text by typing/pasting, which is cool. Is there anything about the number of... KB? that you can have in your library? Or will too many slow down the system oorr anything like that? Just in general.

Thanks for this again! That must have taken some time to hash out. I will definitely use this for words that I want the option of changing the case without making separate macros. Cool!

The blue/grey striped color indicates that the Action is found in a KM Search you have executed (upper right corner or KM Editor). Clear the Search and the Action colors will be restored.

I assume you mean "macros" by "... KB". In general I have not found KM to slow down with the number of macros I have. I suppose if you were to have many hundreds of Macros Active at the same time, there could be a slowdown.
So, try to limit the number of Macros that have global activation (for all apps/windows).

You're welcome. I hope you and others find it useful, and a good example to help you develop other macros.

If you have more questions not specifically related to this macro, please post as a new topic.

1 Like