Hi, I have an approach to the problem that uses JavaScript and is very fast in operation.
There are two macros that I have written: the first returns all the multiple matches plus capture groups (if any are specified in the regex). The second macro is slightly different in that it returns only the capture groups. Both macros return an array that contains the matches plus variables that indicate the number of matches. Refer to comment at the start of each macro for usage information. Both macros avoid the need for a KM looping structure.
While I don't pretend to be either a JavaScript nor KM expert, I use these macros daily very successfully to extract information from both web (HTML) pages and text documents. I hope you can find a use for them.
These may be of use to you
Here they are:
The first macro libGetAllMatches.kmmacros (7.4 KB)
The second macro libGetAllCaptureGroups.kmmacros (7.8 KB)