How to Evaluate Loads of Cases?

I am trying to write a macro that adds the plural ending to Dutch nouns, based on the ending of the singular noun. Plural can get one of three possible endings (-s, 's and -en), based on the ending of the singular noun.

The macro has to evaluate a lot of endings.

My question: Isn't there a more compact way to evaluate the endings, e.g. via aar|aard|e|eau|el|em|en|er|erd|eur|foon|ie|ier|oor|um (for the first plural ending)?

You're already halfway there with the syntax. Just use "matches" instead of "ends with" and the regular expression (aar|aard|e|eau|el|em|en|er|erd|eur|foon|ie|ier|oor|um)$ for the match term:

You can use the same syntax for any other term with multiple possible matches by separating them with the pipe character.

1 Like

Hey Hans,

Something like this?

-Chris


Plural Ending v1.00.kmmacros (6.5 KB)
Keyboard Maestro Export

1 Like

Gurus -- can you use modifiers in this match field? For example

(aard?|erd?|...)$

...to match aar, aard, er and erd?

That should work – test and see.  :sunglasses:

Given the number of silly mistakes I'm making today I'm not sure I trust myself, but (aard?|e(au|l|m|n|rd?|ur)?|ier?|foon|or|um)$ does seem to work.

Whether saving twelve characters is worth risking extra errors is another matter!

2 Likes

Thank you!

The whole algorithm became:

Not bulletproof, of course.

1

2 Likes