For Each Action Only Finding First Substring

I thought these actions previously worked to loop through and process each substring. However, I don't recall making any changes, but I'm not 100% certain it has worked since upgrading to Keyboard Maestro 10.0.1 on macOS 11.6.1 either. I'm having difficulties debugging why the remaining substrings or Release_Item(s) are not found and would appreciate some suggestions to check. It is probably something obvious that I'm missing since appears to capture each Release_Item, but the For Each action only captures the first substring.

The ReleaseItem_Data variable contains:


The substring capture regex is:


For Each.kmactions (65 KB)

Keyboard Maestro Export

Your regex to break up the data into substrings starts out with ^ which anchors it to the beginning of the string. Only the first match at the beginning of Data will match it. Remove the ^ at the beginning and it may work. May because when I did that, I only matched the first 2 strings. I think there is something wrong in your regex (or my typing of it) that caused the last one to mismatch.

It might be better to use a regex like this:

⌘\$[A-Z]\$\d+⌘\d+⌘[A-Z ]+⌘[A-Z0-9/\-\. ]+⌘\$[0-9\.]+⌘(TRUE|FALSE)

That matched all 3 strings for me. It doesn't try to be as precise as yours so it may not actually work for you. Couple of things I noticed:

You don't have to escape every "weird" character, I've been finding lately if I do this it breaks the regex. So the ⌘ doesn't need to be \⌘

I removed the grouping parentheses as they aren't used for anything in this particular regex (it worked with them in just the same).

I see you're using [0-9] in some places so I assume you know that means any character in the range of, but you can stack as many additional characters into the brackets as you want and it'll work as "find one of any of these characters) so where I do [A-Z0-9/-. ]+ that means any upper case letter, any digit 0 to 9 the forward slash, the dash (has to be escaped) the period (also escaped), or a space.

Hey @KM_Panther,

When posting something like this please:

  • Use the preformatted-text button in the forum editor to post text that needs to be seen verbatim (not rendered by the browser) – like data and regex patterns.
  • Post a complete macro rather than a set of actions.
  • Provide the data IN your macro, so helpers don't have to fight with it.

I have fixed your original post.

It looks like Steve has solved your issue.

Take Care,

(Keyboard Maestro Moderator)

I have retracted a confusing post

In my initial posting, I indicated that I "thought" this action worked previously. In fact, I know it has worked previously for a long time and I have not modified this macro and have used it for some time. It is a very long macro and I thought it was not useful to post the other unrelated actions, but I will include full macros when requesting support in the future.

Thanks for the instruction on posting text that needs to be seen verbatim and the regex recommendations for the resolution of my issue. As suggested, removing the caret (^) enabled the For Each action to loop through each substring. Still not sure what changed.

Don't do that unless it's really necessary.

When possible post the smallest possible test case that demonstrates your issue.

In this case you only needed to copy what you posted into a new macro and add a data variable.

Everything after the search action could be removed and replaced with a display text action that displayed the found variables.

Short, sweet, and easy to test.

Keep in mind – the easier you make it for others to TEST your work – the more likely you'll get timely and quality help.

Trying to debug macros by eye is largely a waste of time. We need to test.