How to remove the extra double quote?

后端 未结 5 1943
再見小時候
再見小時候 2021-01-26 02:37

In a malformed .csv file, there is a row of data with extra double quotes, e.g. the last line:

Name,Comment
\"Peter\",\"Nice singer\"
\"Paul\",\"Love \"folk\" so         


        
5条回答
  •  面向向阳花
    2021-01-26 03:29

    In Ruby 1.9, the following works:

    result = subject.gsub(/(?

    Previous versions don't have lookbehind assertions.

    Explanation:

    (?

    Of course this assumes that we won't run into pathological cases like

    "Mary",""Oh," she said"
    

提交回复
热议问题