Case Sensitive Conditions?

Hello, I am trying to set a condition on a macro, and I need it to be case sensitive. Problem is - it's not. Here's a setup:

In this example I'd like the macro to execute only if the variable "TestVar" contains the text "Condition", with a capital "C". It is currently executing on "condition" with a lowercase "c". Is there any way to achieve the desired result here?


Looks like setting it to "matches" instead of "contains" is doing the trick. So problem solved? Anybody know if I'm in for any surprises by setting it to "matches"?

Hey @cmizle,

Matches is a regular expression, so yes there are potential pitfalls.

See variable condition on the Wiki.


Gotcha - looks like everything in that list is specified to be cases INsensitive. The "matches" thing is currently working for me so I guess I'll leave it for now - but I'm very open to hearing about any other option of creating case sensitivity.

Hey @cmizle,

It's the only option you have at present.

Matches is case-sensitive by default, but you can turn that off as I have in the appended macro with a regex pattern modifier.

You'll note that I'm matching much more than a simple string.

The potential problem when using Match is that you might use one or more regex metacharacters by accident and create an unexpected match or failure to match.

Take a look here to get a glimpse of what could be problematic:

Regular Expression Metacharacters


Matches Example v1.00.kmmacros (8.4 KB)

This is awesome, thank you so much. I think this will solve my issue. Much appreciated!

1 Like

The regex page you linked is very handy. I'll have to study that further! :grinning:

1 Like