in reply to Re: split on comma-separated fields, where a field may have commas inside quotes
in thread split on comma-separated fields, where a field may have commas inside quotes
Then there's the issue about quoting quotes, which wasn't mentioned in this problem, but would probably come up eventually in any real-world case that gets used much. And reporting errors on malformed lines.
That said, I've got a regex that at least seems to deal with the empty fields properly:
/(?:^|,)((?:"[^"]*"|[^",]?)+)/g
|
---|