A program has users typing in a comma-delimited string into an array:
basketball, baseball, soccer ,tennis
There may be spaces between the commas or maybe not.
If this string was simply split()
on the comma, then some of the items in the array may have spaces before or after them.
What is the best way of cleaning this up?