I have a same question so i copy this topic again

I need to loop through the matches of a variable, inside another variable. I'm not sure whether the substrings field accepts the variables and in which format.

The below format is not working.

thx all

Hi @quanghieuci,

At first glance, I can't see any reason why your loop wouldn't be working. This example macro, which looks to be set up the same way as yours, works fine for me:

Example Loop.kmmacros (4.2 KB)

I'm afraid we can't tell from that screenshot alone what might be causing the macro to fail, so if you could please follow the instructions here to post your full macro, we'd be much better equipped to figure it out: https://wiki.keyboardmaestro.com/Forum#How_to_PostUpload_Your_Macro_to_the_Forum

What are the values of the variables zzzKeyword, zzzResult and zzzKeywordCounter before the For Each action.

Keep in mind “matching” means regex, so if zzzKeyword includes regex characters, then they will have special meanings.

Also, if zzzKeyword has any extraneous characters (eg a return character), then that would stop your match.

Also, whenever asking your question, is it best not to simply say “is not working”, but to explicitly say what is not working. Is it failing to find any match (and so zzzKeywordCounter is remaining 0, presuming you set it to 0 before hand)? Is it finding too many matches? Is it giving an error?

1 Like