need a regex to parse a csv file with double quotes in php

不羁岁月 提交于 2019-12-02 02:51:52

问题


Trying to parse a csv file that has all the data wrapped in double quotes, because there may be commas in the double quotes.

Looks like this:

$songs = '"1, 2, 3, 4 (I Love You)","Plain White T's","CBE10-22",15,"CBE10-22","","","CB",984,"","10/05/10"';

$regResult = preg_match( "", $songs, $matches );

I can't figure out a regex that will return the data between the quotes as the matches. I'm sure there is some regex master that can help me with this.


回答1:


you dont need no stinkin regex to parse a csv file in php.

see fgetcsv() and str_getcsv()



来源:https://stackoverflow.com/questions/4637989/need-a-regex-to-parse-a-csv-file-with-double-quotes-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!