Syntax of regex in Press Button action

I'm having problems to determine the correct syntax of a regex in the Press Button action. The button label can contain letters, dashes and underscores and always ends with '_tm':

Screenshot 2024-03-27 at 09.26.18

My first attempt doesn't work:

(When I write the full label, the action works fine.)

The documentation says:

Alternatively, you can start the name with an ^ and use a regular expression to match the button name.

When I remove the word "Description:" it works for me.

But there may be a second problem. You might have to remove the "?".


I think I'd set it up as ^[\w-]+_tm

But based on your description of what characters the button can consist of, it could be set up more strictly (removing more possibilities for false positives), using this expression ^[a-z_-]+_tm$

If you'd drop the question mark from your expression it should also work. It'd then match absolutely anything as long as it contains "_tm"

I strongly recommend using when building, testing and learning regular expression. You'll quickly be able to see what the expression matches, and also see an explanation for all the different tokens used in the expression

Edit: Removed the pipes from the character groups, as I realised they're not needed (and where in effect themselves inadvertently added to the pools of matching characters). And if you'd want to follow @Nige_S proposition bellow, to also accept capital letters to the strict expression, it would look like this ^[a-zA-Z_-]+_tm$


As @Airy says, remove everything before the ^.

Do note, though, that this regex doesn't do what you say you want! It'll match any button with "_tm" in its name, regardless of position. If you do want to make sure it is at the end, anchor it there with $:


...or use @Alexander's version to reduce false positives (you'll want to add A-Z if there might be capitals).