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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

REGEXP_REPLACE - remove commas from string ONLY if not enclosed in ()'s

564484Jun 12 2008 — edited Oct 26 2009
Hello all,

I'm trying to use REGEXP_REPLACE to replace all commas from a string with one exception - they must NOT be enclosed in parentheses to be replaced.

Example:

Before String: 'a, b, c (a, b, c)'

After string: 'a b c (a, b, c)'

I know there must be a clean regular expression pattern that can do this - but I can't get my head around it. I've tried using the "[^\(.*,.*\)]" pattern - but it seems to treat the enclosed pattern as just a list of single characters to NOT match.

I know you regular expression experts probably could answer this in about 5 seconds - so I thought I would post this question...

thanks very much...

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Nov 23 2009
Added on Jun 12 2008
7 comments
44,051 views