On Mon, Feb 17, 2014 at 09:32:24PM -0800, Alan Truly wrote:
> Another case to be wary of is if you have double quotes in your text. They 
> are encoded in the CSV as 2 double quotes. 
> 
> So for example:
> 
> name                 story
> George              He said, "Hello!"
> Jeff                    I agree with George
> 
> Would be encoded as:
> "name","story"
> "George","He said, ""Hello!"""
> "Jeff","I agree with George"
> 
> In this scenario, Christopher's grep works, but Ronald's fails.

I forgot to account for double quotes within the field containing the
comma.  Here's the fixed version:

(\"(?:[^\",\r]|\"\")*),((?:[^\"\r]|\"\")*\")(?=(?:,(?:[^\",\r]+|\"(?:[^\"\r]|\"\")*\"))*$)


Note that Christopher's grep does not account for enclosed double quotes at
all.  It happens to work on your sample input, but it turns
"""","field"
into
""" "field


Ronald

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].

Reply via email to