I have the string: X(1) X(2) X(4) Y(2) Y(3) Y(7) Z(4) Z(5) Z(6)

and I want to reduce it to: X(1)(2)(4) Y(2)(3)(7) Z(4)(5)(6)

Any suggestions?


Well. At least I won lunch.
Good philosophy, see good in bad, I like!