How Do I Allow For a Variable Number of Lines to Process?

yesterday, they help me solve some problems. thanks very much.

I still have some problems, In my Macros:

  • With the language of javascript, I get the icafeName(all name), the format of icafeName is:
  • I get the count(length of icafeName). The count is 3 (three lines) in the above situation . But in fact, they are mutable, from 2— 5.

In the macros "using regular expression", they are saved in "testVar1", "testVar2", "testVar3".

My demand is :In the Repeat Actions macros, typing the name respectively, first use the testVar1 (, then use testVar2(

But in fact , in the Repeact Actions, the variable is fixed,(var1 is different from var2).How to solve this problem?


ask remind group create icafe.kmmacros (7.2 KB)

While there is a way to do exactly what you're asking, there's also a simpler way to go about it. You don't need to count the addresses and save each one to its own variable to accomplish this; using the For Each action (one of the single most useful actions in KM, in my opinion) you can have your macro paste as many addresses as you collect in your icafeName variable automatically:

ask remind group create icafe 1.1.kmmacros (5.4 KB)

1 Like

@jogging, I hope you don't mind that I have revised your topic title to better reflect the question you have asked.

Get different variables in the Repeact Actions

How Do I Allow For a Variable Number of Lines to Process?

This will greatly help you attract more experienced users to help solve your problem, and will help future readers find your question, and the solution.


As you have seen, the KM Search using Regular Expression action does not allow for a variable number of Capture Groups (lines in your case).

As I pointed out in your other thread, and @gglick suggested here, it is better to use the KM For Each action with a lines collection, for a use case like yours.

1 Like

thank you very much. You help me solve the problem.

1 Like

thank you very much. ,,You help me solve the problem.