I'm terrible with regex stuff. I have data that looks like this:
abc,42,4/04/1992,,,something, ,2/05/2007,dkwit,,334,,,
The meaning of the data itself is somewhat irrelevant, the point is that it's comma-delimited, you could refer to the data between commas as "columns", and some columns may be whitespace or empty (later on, whitespace columns and empty columns are ignored). I need to split the string into an array based on the comma delimiter. I tried
new StringTokenizer(string, ",")
but that will skip over tokens where the data between columns is empty, so I tried using string.split(",")
. The problem with that is it would skip the last three columns in the data above. You could say after the "334", it behaves like StringTokenizer, skipping the columns with no whitespace or no data in them.
Can I make string.split( )
behave in such a way that it will continue to split until it comes across an end of line, or is there a better way to do this?