Regex Behaving Globally?

I'm trying to make a Search and Replace function that takes the clipboard, containing the definition of a word from Merriam-Webster.com, and removes everything between the end of the first word and the first colon.

Using Regex101.com, set to be non-global and non-multi-line as per
RegEx: Global and Wiki, this appears to work:

image

BUT – the result the KeyboardMaestro function gives comes out different—

precarious:::::

I'm stumped. Any thoughts would be appreciated.

Cheers!

Could you do two matches, then join them?

  • first word to var1
  • everything after and including first colon to var2
  • set var3 to var1var2
1 Like

Thank you, that's a good idea– I think it would fix this, I just wonder if there's some larger gap in my knowledge here about how RegEx work in KeyboardMaestro, as I use them for several things.

It would help to see your macro. Sometimes, subtle changes can make a regex produce very different results.

1 Like

Thank you! This prompted me to discover there is a First Match setting in the RegEx function:

image

1 Like