Not sure if I my ask is using the correct description. Hopefully the image will help explain. I am trying to run a for each over geo that has a bunch of names. Or create groups from each common name block, and then be able to run a for each group etc. The names have common syntax but are not identical. So instead of having 4 "Lace" names I'd love to figure out how to group them to 1 "Lace" group.
Another issue is that I'd like to be able to do this with out knowing what names are present. I know that I can create groups if I already know the partial name, midsole, lace etc. using something like "@name=*ace*" But if I don't know those names. Is there a way to find the common name string and group them.
1) Take the name string up to the first non-letter character and add them to a list if they are not already in the list. This will give you a list of unique 'starter' strings.
2) sort the list by length, longest ones first. this is to help keeping "part_1234" and "partOther_1234" apart.
3) loop over list items and group them by item*. Make sure to only add to the group if it's not in a group already. This in combination with the sorting will avoid the "part" group from getting the "partOther" items.
Edited by Jonathan de Blok - Dec. 11, 2023 18:37:53
If the text you're trying to match have a similar pattern (like I see on your screenshot) you can use regex which is a powerfull way of detecting text and capturing section.
I've tweaked the hip file a bit for more robust output and to create actual groups as well while we're at it.
What it does is takes the first part of the string and uses that as main part name, the other matches are kept as an array of subnames. If you look at the input 'name' attrib values you can see I've made them extra messy yet the 'part_name' and 'part_subnames' values come out quite nicely.
Edited by Jonathan de Blok - Dec. 12, 2023 04:01:11