Is this IF/THEN action true or false?

Is this IF/THEN action true or false?

I have copied a REGEX101 expression (.a...) and pasted it into both If actions in both the text and contains blocks. Both actions show TRUE until I manually edit the second If action and replace the a with a numeral 1. the second action then shows FALSE. What am I missing here?

if test.kmmacros (2.4 KB)

Hey Dennis,

Contains is a literal text operator...

condition:Text [Keyboard Maestro Wiki]

If you want regular expressions then you need to use matches.


Hey Chris,

Thanks for the quick reply.

In the first IF action I changed from contains to matches.

Still evaluates as TRUE.

Edited (.a...) to (.1...) in both blocks.

Evaluates as FALSE.

But if I copy/paste (.1...) from the matches block to the text block, it evaluates as TRUE.

Please help this 70 old brain.

Here's what Chris is suggesting (and which delivers the expected results) and what it appears you may not quite have, um, matched:


Regex matching explanation that you may not want to bother with. The important point is next...

In the "The text:" field, "(.a...)" is the literal string "an opening parenthesis then a period then an a then three periods then a closing parenthesis" -- similarly for (.1...) but with a 1 instead of an a.

In the "matches" field, ( marks the start of a "capture group", the first . matches "any character except a line terminator", then you match an a, then three more "any characters", and the ) closes the capture group.

So "matches (.a...)" will be true if the text is "(.a...)" because the text includes "something then an a then three somethings". "aaaaa" would also be matched, as would "bacde", etc -- but not "aaaa" (not enough characters) nor ".1..." (because the second character isn't an a).

Similarly "matches (.1...)" will be true if the text is "(.1...)", "11111", etc but not ".a..." nor ".1..".

What you do need to watch out for is three consecutive .s being replaced by an ellipsis, which is what has happened in the second "If" action of the macro you posted. The text is then "opening parenthesis then a period then a 1 then an ellipsis", which won't match your "contains" and doesn't have enough characters to match your regex.

If you squint you might be able to differentiate between "..." and "…" -- easier to put the insertion point in the field and use the arrow keys to move back and forth, watching for an unexpected jump.

1 Like

Thank you Nige, do you know how to stop this auto-correct in Ventura? I have been searching since seeing your reply with no success.

Where did the text come from? If you typed it in KM then it's because of System Settings -> Keyboard. Go to the "Text Input" section and "Edit..." the input sources, and turn off "Use smart quotes and dashes".

If that's already off then it's an application setting -- for example, in TextEdit you can find it in Edit -> Substitutions where you can turn off "Smart Dashes", in Word it's Word -> Settings... and the AutoCorrect pane where it's listed as a replacement in the bottom scroll area, etc.