Hey Ciprian,
Since you're dynamically assigning a variable number of lines in the clipboard to individual variables RegEx is not really the best tool for this task. RegEx cannot dynamically change the number of captures in a pattern.
Here's a relatively simple macro that will assign each line in the clipboard to a numbered variable.
textVar_1
textVar_2
textVar_3
...
- Copy your text.
- Run the macro.
- Examine the Variables panel in the KM preferences for the listed variables.
==EDIT – New version v1.03 posted 2021/03/27 16:51 CDT==
Dynamic Assignment of Variables v1.03.kmmacros (10 KB)
Now then – the pitfall with this is that the variables are not ever deleted.
That means that subsequent runs of the macro will overwrite the existing variables, and that can be problematic if it doesn't overwrite ALL of them – you can end up with extraneous variables.
So – we need to know a bit about your workflow to decide the best place to do variable housekeeping.
To delete them en-mass you can do something like this:
Execute an AppleScript.kmactions (788 B)
But not until you've processed them.
-Chris