Switch ends with bug

Test switch error.kmmacros (4.2 KB)

The line does end with .png.

I just tried this action and it worked as expected.

Perhaps you have an invisible character in there somewhere (a space or newline or other invisible character)?

No special or invisible characters. The text is aaaaa.png2.png
and the ends with is .png

Are you sure you did not enter a RETURN after the ".png" in your variable setup?
I've used this KM IF/THEN Action many times, and it works well. I would be shocked if there is a bug here.

If you are sure, then upload your macro so we can test.

I uploaded here: Keyboard Maestro 8.2.4 “Test switch error” Macro

You have some type of hidden, non-printing character at the end of your string.
When I replace ALL with my typed string, it works fine:


You're changing the string, of course it works fine.
The bug happens with

When I use myPath.myFile.png I don't get the bug either. I don't have any special character, I am not even copying and pasting.

I stand corrected. It does appear to be a bug.
Here's a workaround:

EDIT#2 2019-04-27 15:04 GMT-5

Here's a better Regex:

It is case insensitive, and ensures there is a dot just before jpg OR jpeg.


@peternlewis, can you confirm?

1 Like

Just made an update to my above post.

1 Like

Just uploaded an even better RegEx.

1 Like

Thank you JMichaelTX!

Sorry, you are quite right, it is a bug, I will fix it for the next version.