@peternlewis,
Issue With RegEx in For Each to Extract First String in Each Line
The For Each with Substrings in Collection with a RegEx does NOT seem to be working properly.
RegEx:
(?m)^(.+?)\t
this should find ONLY strings at the START of each line.
But it is finding all strings that are followed by a TAB.
RegEx101
See https://regex101.com/r/MR2hES/1
MACRO: TEST RegEx in For Each to Extract First String in Each Line
-~~~ VER: 1.0 2021-05-27 ~~~
Requires: KM 8.2.4+ macOS 10.11 (El Capitan)+
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))
DOWNLOAD Macro File:
TEST RegEx in For Each to Extract First String in Each Line.kmmacros
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.
1 Like
Yes, it looks like ^ will match at the start of the search string each time, which includes after any matched string.
I will look at resolving that for a future version.
In the mean time you can work around the issue by adding a leading linefeed and using a positive lookbehind assertion (?<=\n)
instead of (?m)^
.
1 Like
Thanks. Hopefully that will be soon with a dot update for Ver 9.
I don't like that workaround since it requires modifying the source data.
So save the change to a new variable and use that instead.
Anyway, your choice, it may be a long wait otherwise.
Or match in Text \n%Local__TableData%
1 Like
That, of course, is entirely up to you.
I would think that many other users are being confused and affected by this bug.
Is it really that hard to fix?