note
Roy Johnson
This sub-thread effectively underscores why it's such a Good Idea to use modules. There are numerous edge cases that make this a difficult problem. Chief among them: what about empty fields? Certainly they should be possible, so you can't just grep them out. But you don't want to introduce them, either.
<p>
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.
<p>
That said, I've got a regex that at least seems to deal with the empty fields properly:
<c>
/(?:^|,)((?:"[^"]*"|[^",]?)+)/g
</c>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-300037">
<hr>
<small><b>Caution:</b> Contents may have been coded under pressure.</small>
</div></div>
770143
770151