02-11-2019 07:44 AM
Hello,
I am trying to search multiple matches from a string.
The Search/Split or Match Pattern only finds the first match but is it possible to create an array of matches for example?
The match im searching contains multiple versions and I am trying to create an array of them.
Can anybody help me out?
02-11-2019 07:59 AM
02-11-2019 08:15 AM
Hi GerdW,
Thanks for the quick reply but the loop just keeps searching the same first version when im trying to build an array of all the versions from the response string. Picture below:
02-11-2019 09:01 AM
You need to use a shift register. You initialize it with the full constant. Then inside the loop, you refresh it with the "After Match" string, so the next iteration it can search for the next match.
02-11-2019 09:02 AM
Yes you are finding the same string every time because you never remove that first line from the search.
You have lots of option as to how to fix this:
1) convert your input string to an array (look up Spreadsheet String to Array in the String Pallette) before you enter the for loop and use auto-indexing to feed the loop each array item (No need to wire N itterations with auto-indexing).
2) use a shift register and wire the remainder after match to the shift register to be used for the next loop. If you use a shift register you need some logic to get the loop to stop when all matches are found. (Hint: while loops or For loop with conditional termination enabled.)
3) a shift register that keep track of the oftset position of the match after every loop and feeds it back into the next loop.
Options 1 and 2 are easier, but it really depends on how your real input is formatted. If there's always a \n then
Craig
02-11-2019 09:03 AM
Hi Teba,
better suitable is "Match Pattern" and the input "Offset" in combination with "Offset past Match".