Regex Problem

I have the following macro as a test. I am trying to remove everything after a [ including the [

This works in regex 101 but not in KBM. I must be doing something stupid.

I see no errors with your RegEx, and it works fine on mine.

You can see in this screenshot that the live results is showing it without the bracket and superfluous text. (click to expand/collapse)

You might try relaunching the KM Engine and/or Editor. If that doesn’t work, reboot and see if it is still broken.


Thanks for the suggestions Chris and I tried each one and no success.

Could there be something with my system that is causing the problem?

Or maybe need to reinstall KMB? [Did this no success]


My guess is you've got an extra space character after the dollar sign in your regex.

Keyboard Maestro 11 doesn't require you to waste time figuring out regular expression problems here.

(It gives you the result directly, in the form of a variable array with "[" as the custom delimiter).

String until first [.kmmacros (2.5 KB)

See: manual:Variable Arrays [Keyboard Maestro Wiki]

(see also: XY problem - Wikipedia)



I'm beginning to think it is something within the OS


Please use the Share feature to share the macro, so we can take a look at it. I can't think of any KM- or Mac-related reason why it wouldn't work, but seeing the actual macro is the only way for us to test what you're using.



Let me look at this and see.


The macro worked great. I have never tried to use arrays but will now try them.

Still do not know why the regex dose not work?


The answer is in the other thread you posted, which will (hopefully) get moved here soonish :).


Search and Replace Action (v11.0.2)

Search and Replace.kmactions (795 B)

Keyboard Maestro Export

Some things I have tried:

  1. Deleted kbm and re installed. Hoped this did the engine also (no help)
  2. Tried to us a different character than [ (no help)
  3. Restarted the computer (no help)
  4. Created just this macro to get it simple (no help)
  5. Used Regex 101 to check (worked on Regex 101)
  6. Checked to make sure right keyboard is selected (no help)

Here is my system
Processor 3.8 GHz Quad-Core Intel Core i5
Graphics Radeon Pro 580 8 GB
Memory 8 GB 2400 MHz DDR4
Startup disk Macintosh HD
macOS Ventura 13.6.3

Keyboard Maestro
Version 11.0.2

This really should be part of this thread, but I can't move things, so someone else will have to fix it :).

Thanks for posting, and it's clear now what the problem is: You can't see it, but your regex isn't what it seems to be. Instead, it's this:


Somehow, you have it repeated four times. To see this, select all in that field, copy, then paste into TextEdit (or a text field in Keyboard Maestro). To fix, select all in the regex line, delete, then just type it in one time.


1 Like

You are correct. Don't know how I did it but that fixed it.


Hey fellas, I merged the two threads. @griffman nice job catching those duplicate lines in his RegEx!

I really wish KM would auto-expand every text field, as it does for some, so that all lines always showed. I've caught myself doing this many times, and have gotten into a copy/paste routine to check for mistakes when something isn't working even though it appears it should be working.



I agree. If there's a lot of text then expansion could be limited and a scrollbar appear (not hidden, please).

1 Like

I agree. This, to me, seems as obvious as allowing the "Wide" option for the Prompt With List action to actually be wide.

I had opened a new thread with my request as an actual feature request, but sadly, Peter said it's not possible:

These are a different kind of field, so they don't expand, or have any ability to expand. It's been a long standing issue across macOS that you can get return characters into them and then have no idea that they are there.

The good news is that it looks like he might be able to at least add some visual indicator that there's more than one line of text in the field, which would be good enough for me.