Have you tried simple RegEx? It generally works very fast.
Here's an example with 57 lines that runs very fast.
Try it with you 2400 line array. Just change the RegEx to Search a file instead of a variable.
Example Output
MACRO: Extract Number from Text Given Keyword [Example] @Regex
That's why I love this community!
Thanks a lot @JMichaelTX. That was insanely fast.
Right now I am just searching from Variable array. Is there any advantage to using a Txt file instead of Variable?
I mean I am pretty impressed with the speed already. It's insanely fast!
Certainly. As one possible way to do this, we can tweak @JMichaelTX's example macro to use the For Each action to collect each matching keyword number into one results variable:
To use this macro with a text file instead of a variable (either should work fine, but I imagine it would be more convenient to use a text file if that's what the array is already in) just change this option in the For Each action:
Gabe, I didn't notice until after my above post, but you also changed my RegEx pattern:
Mine is: (?mi)^%Variable%Local__KeyWord%,(\d+)
The key difference is that mine requires that the keyword start at the beginning of the line. I haven't tested yours, but I believe it could yield a false positive if the keyword was partially contained in another line, as in:
123456,12
456,9
I believe your RegEx would find the first line for a keyword of "456".
I'll leave it up to you to test and confirm/refute my assertion.