Regex find comma not inside quotes

前端 未结 5 1997
不思量自难忘°
不思量自难忘° 2020-12-05 07:52

I\'m checking line by line in C#

Example data:

bob jones,123,55.6,,,\"Hello , World\",,0
jim neighbor,432,66.5,,,Andy \"Blank,,1
john smith,555,77.4,         


        
5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-05 08:13

    The best answer written by Vasili Syrakis does not work with negative numbers inside quotation marks such as:

    bob jones,123,"-55.6",,,"Hello , World",,0
    jim neighbor,432,66.5
    

    Following regex works for this purpose:

    ,(?!(?=[^"]*"[^"]*(?:"[^"]*"[^"]*)*$))
    

    But I was not successful with this part of input:

    ,Andy "Blank,
    

提交回复
热议问题