I am trying to parse two levels of structure in a string. The input can of form.
x1:x2:x3::y1:y2:y3
--> where there can be more chaining with ::
The regex should be able to parse the string through ::
in the first go, and then each group through :
.
Output should look like:
x1, x2, x3
and y1, y2, y3
I have been able to figure out parsing one level by capturing the group.
(^[a-zA-Z\d]+):([a-zA-Z\d]+):([a-zA-Z\d]+$)
How do we make it work for two levels of parsing?
On the lighter note, would you prefer just using Split
to make it simpler? I prefer regex as it has cleaner checks on data organization.