Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Replace characters between characters throughout a string

Tony.A-OracleOct 18 2013 — edited Oct 19 2013

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

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 16 2013
Added on Oct 18 2013
4 comments
890 views