Keyboard Maestro 9 adds new text case conversion characters. These are typically seen in other languages in the replacement section of a regular expression search & replace. And they do indeed work nicely in the Search and Replace action, but they also work in any other token Text Field.
The Available Case Conversion Meta Characters are:
-
\U
converts everything up to the next\L
or\E
to uppercase. -
\L
converts everything up to the next\U
or\E
to lowercase. -
\u
converts the next character to uppercase. -
\l
converts the next character to lowercase. -
\U\l
lowercase first, then uppercase. -
\L\u
uppercase first, then lowercase. -
\E
stop changing case.
You should not use \u
after \U
or \l
after \L
unless you terminate the sequence with \E
first.
So for example, if you want to properly case a two word name in a variable “Full Name”, you might use an action like:
Search for (\w+)\s+(\w+)
replace with \L\u$1 \L\u$2
.
That is, find a pair of word character sequences separated by space characters, and replace them with the words lowercased, except the first character uppercased.
Or if you want to have a variable “Important” interpolated in a message in uppercase, you might do something like:
This would include the text from variable “Important” in uppercase.
Keyboard Maestro 9 also supports named capture groups (in OS X 10.13+), for example, with the variable “Example” holding something like “The name is Fred.”, this:
Search for The name is (?<Name>\w+).
and replace with ${Name} is the name, and the name is really ${Name}!
would result in “Fred is the name, and the name is really Fred!”
Usually this would be overkill, but for a complex regex, it could be handy and help document what the regex capture groups are.