I have a large comma separated string that can at times contain "fields" that spans multiple lines - when this happens, as is common with csv files, these fields are enclosed with double quotes. What I'd like to do is using a regular expression to remove any carriage return / line feeds from the string if they appear between two double quotes.
For example, starting with this string:
Tab2,ABC,Project,,,XYZ,123456789,XYZ Upgrade,Scheduled Unfunded,52037.00,10/25/2013,10/9/2013,,"this is a really long comment that contains a cr/lf
and ends up on two lines",
or
Tab2,ABC,Project,,,XYZ,123456789,XYZ Upgrade,"Scheduled Unfunded
second line",52037.00,10/25/2013,10/9/2013,,"this is a really long comment that contains a cr/lf
and ends up on two lines",
I'd like to end up with:
Tab2,ABC,Project,,,XYZ,123456789,XYZ Upgrade,Scheduled Unfunded,52037.00,10/25/2013,10/9/2013,,"this is a really long comment that contains a cr/lf and ends up on two lines",
Tab2,ABC,Project,,,XYZ,123456789,XYZ Upgrade,Scheduled Unfunded second line,52037.00,10/25/2013,10/9/2013,,"this is a really long comment that contains a cr/lf and ends up on two lines",
I've been trying to understand the regular expression syntax and using things like
[code]
'"(.*?)'
[code]
but so far I haven't found anything that works across the entire string.
Is this type of replace possible via regular expressions or do I need to look at a custom loop type of solution?
Tony