I need to separate the input string with commas, half-columns or spaces (or a combination of the three). I would also like to handle multiple consecutive input delimiters as a single delimiter. Here is what I still have:
String regex = "[,;\\s]+";
return input.split(regex);
This works, unless the input line starts with one of the delimiter characters, in which case the first element of the result array is an empty line. I don’t want my result to have empty lines, so something like: ,, ZERO;, ;; ONE, TWO ;, "returns only a three-element array containing header lines.
Is there a better way to do this than to remove any leading characters that match my reg-ex before calling String.split?
Thanks in advance!
source
share