Re: Grep help

2014-02-18 Thread Ronald J Kimball
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!
 JeffI 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
supp...@barebones.com 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 bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.


Re: Grep help

2014-02-18 Thread Alan Truly
No offense meant Ronald. You obviously have a strong understanding of grep. 
There are just so many issues involved with CSV parsing that it is hard to 
catch all of the cases.
 

 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
supp...@barebones.com 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 bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.