I have a CSV line that is comma delimited:
1000102257,b,N,159999,3,4545656,4,,,,"6,125% NORDRHEIN-WESTF.LA.SCHA.R.239 21.12. "18"
The tokens that contains the comma delimiter(,) as content are double quoted to escape it.
As you see, the last token is isolate between double quote, but another double quote appears ("18) which ruins the tokenize mechanism:
"6,125% NORDRHEIN-WESTF.LA.SCHA.R.239 21.12. "18"
This is my code to split in tokens the line:
public static void main(String[] args) {
final String cvsSplitterEscapingQuotes = ",(?=([^\\\"]*\\\"[^\\\"]*\\\")*[^\\\"]*$)";
String strLine = "1000102257,b,N,159999,3,4545656,4,,,,\"6,125% NORDRHEIN-WESTF.LA.SCHA.R.239 21.12. \"18\"";
String[] tokens = strLine.split(cvsSplitterEscapingQuotes, -1);
}
How can I escape the middle double quotes that are inside a quoted token?