In point of fact, using
.split("[; ]") could very well lead to the wrong results if there *ARE* spaces in the string that is split.
Clearly if you had the string
Code:
1 potato; 2 potato; 3 potato more
You would get the array
Code:
1 potato;
2 potato;
3 potato more
if you simply split on ";" (notice the spaces at the beginning of the 2nd and 3rd elements.
).
But you would get
Code:
1
potato
[empty string]
2
potato
[empty string]
3
potato
more
if you split on "[; ]"
Possibly more useful would be to split on ";\\s*" ???
That would get you
Code:
1 potato;
2 potato;
3 potato more
getting rid of those leading spaces.