How to split csv whose columns may contain ,

前端 未结 8 1321
我寻月下人不归
我寻月下人不归 2020-11-22 06:35

Given

2,1016,7/31/2008 14:22,Geoff Dalgas,6/5/2011 22:21,http://stackoverflow.com,"Corvallis, OR",7679,351,81,b437f461b3fd27387c5d8ab47a293d35,34

8条回答
  •  佛祖请我去吃肉
    2020-11-22 07:25

    It is so much late but this can be helpful for someone. We can use RegEx as bellow.

    Regex CSVParser = new Regex(",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))");
    String[] Fields = CSVParser.Split(Test);
    

提交回复
热议问题