[Chicago-talk] Removing Characters

tiger peng tigerpeng2001 at yahoo.com
Wed Oct 24 21:00:17 PDT 2007


And this one will keep the double quote escape by backslash \". But if a backslash is escaped by a backslash, the double quote following the escaped backslash, this double quote is not escaped, will still be  kept.

Phew  ;-& 

's/(?<![,\\])(?:(^")|")(?![,;]|$)/$1?$1:""/ge?print:print'

----- Original Message ----
From: tiger peng <tigerpeng2001 at yahoo.com>
To: Chicago.pm chatter <chicago-talk at pm.org>
Sent: Wednesday, October 24, 2007 10:22:22 PM
Subject: Re: [Chicago-talk] Removing Characters

Thanks  everyone. Here is the one-liner  I am  looking for!
perl -ne 's/(?<!,)(?:(^")|")(?!,|$)/defined($1)?$1:""/ge?print:print' in.csv > out.csv
(-; I have not used my real first name 'Ge' for regex for a while ;-)
I believe the replace character and the delimiter can be a set of character, such as ["'] [,:|].

's/(?<![,\\])(?:(^")|")(?![,;]|$)/$1?$1:""/ge?print:print'




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/chicago-talk/attachments/20071024/696033cd/attachment.html 


More information about the Chicago-talk mailing list