I have a list of objects:
e.g. A, A, B, C, D, E, E
And I have defined templates that tell how object types can be grouped e.g.
Group Alpha --> A 1..n --> any number of 'A's can be grouped
Group Charlie --> Sequences of 'BCD' can be grouped
Group Epsilon --> E 1..n --> any number of 'E's can be grouped
Now I want to apply those group definitions on the original list, which should give the result:
Group Alpha (2x'A'), Group Charlie (1x'BCD'), Group Epsilon (2x'E')
How can this be best achieved? Is there a known search algorithm/pattern for my issue? I have tried a very basic way of looping many times over the list and trying to look ahead from each list entry and match patterns but was totally lost due to the complexity ...
Thanks in advance for any hint !!!