(Help With) Text Expansion/Case Correction w/ Punctuation

I have some macros I use for case correction. I have been using them with Typed String triggers, ending with space, to avoid triggering unintentionally in other words. For instance:

Now I'd like a way to trigger led to LED when led is followed by a space or any punctuation. Additionally, I'd like a way to trigger it when it is the first word in a sentence or a spreadsheet cell. I'd like to do all of this without triggering unintentionally as a part of another word. (Then I'd like to use the same methodology for words other than LED, but I figure y'all already figure that ;))

Is there a way to accomplish these goals all in one macro?

Thank you

See if the macro I just posted will work for you.
It will convert to upper case the text you type of the trigger prefix of:
;uc.YourText and then SPACE or TAB

So,
;uc.led[SPACE] results in:
LED

Please feel free to ask any follow-up questions.

Hey Christian,

No.

You can't detect where a word is in text – certainly not while you're typing it – and especially not if the sentence is the first one.

The following macro uses the %TriggerValue% token to keep your trailing space or punctuation.

The word-boundary regex token in the front of the pattern keeps it from firing in words like “oled”

-Chris


Typed Trigger Example → RegEx Test.ccs.kmmacros (2.8 KB)

This seems to do exactly what I'm looking for. How would I modify this for brand corrections, rather than filtering the variable? For example, bluray to Blu-Ray, saving punctuation? or tvs to TVs? (YouTube, eBay, etc.)

Hey Christian,

Something like this I reckon.

The trigger text for that is:

\bbluray[[:blank:][:punct:]]

Adding parentheses makes it a little easier to see what part you need to change for each new abbreviation.

\b(bluray)[[:blank:][:punct:]]

Now I'm making it case-insensitive to make it more flexible.

(?i)\b(bluray)[[:blank:][:punct:]]

You can get fairly fancy.

-Chris


Typed Trigger Example → RegEx Test 02.ccs.kmmacros (3.0 KB)

Yes, I’ve figured out how to change the trigger for new abbreviations. The case-insensitive is very useful. Is there a way to correct multiple errors to one correction in on macro (blueray, blu ray, bluray, blu-ray, etc., all to Blu-Ray) or will I need separate macros?

Thank you for your help.

Hey Christian,

Sure.

blue?[[:blank:]-]?ray

OR

(?:blu-ray|bluray|blu ray|blueray)

As I said – you can get pretty fancy. :smile:

-Chris

Whups – I should have tested in Keyboard Maestro instead of BBEdit…

\bblue?[[:blank:]-]?ray[[:blank:][:punct:]]

OR

\b(?:blu-ray|bluray|blu ray|blueray)[[:blank:][:punct:]]

-Chris

Excellent! Thank you. Just more evidence that I need to buckle down and learn regex.