Selecting only text in brackets with search/replace clipboard action

In the text saved to the clipboard, I want to extract the text in brackets (only one pair of brackets in the text)

I think (hope) that the following regex should extract the text in but

  • I am dumbfounded as to what I should write for "replace"
  • I only want the text within the brackets, not including brackets

thanks in advance for your time and help




Your regex is incorrect, it should be:


and you are extracting a match not replacing it, so try a Search Using Regular Expression action like this, for example:


Have a look at the KM wiki page: action:Search using Regular Expression [Keyboard Maestro Wiki]

If you want just the text (not including brackets) use this:





great ! thank you

Regular expressions (or simpler splits on [ and ] characters) should work over some inputs, but will struggle a bit with a more general set of possibilities.

Consider, for example:

There is an [innermost [bear] in the courtyards] of the palace.


are you referring to multiple nested [text] or simply multiple [text] ? thanks very much

Nested ( recursive ) patterns are classically beyond the scope of Kleene algebras (regular expressions), though some implementations make efforts to get around that architectural constraint.

1 Like

thank you @ComplexPoint