如何在csv文件中拆分包含逗号的字符串

时间:2017-08-07 17:24:20

标签: java regex

我的字符串如下:

"18","1st",0,"Beattie, Mr Thomson",36.0000,"Cherbourg","Winnipeg, MN","C-6","","","male"

我想用逗号分割字符串,使用split函数忽略引号内的逗号。

我试过这个

  

line.split( “(:(:?\” \ W * \ “| \ d *)),(:(:?\” \ W * \ “| \ d *))”)< / p>

1 个答案:

答案 0 :(得分:0)

有足够的现有模块可以导入CSV文件。例如https://commons.apache.org/proper/commons-csv/