I’d like to split the following string into three elements:
first, middle, middle, middle, middle, last
So the result would be:
splits[0] = "first"
splits[1] = "middle, middle, middle, middle"
splits[2] = "last"
I don’t know if this is best done by regex or string methods.
An alternative way of doing it would be this:
I think the second solution is cleaner and easier to understand. But it has the disadvantage that the first and the last comma must be followed by a space. This requirement does not exist for the first version.