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

Viewed 6451

I find an example at oracle forum site :

Input string : a, b, c (x, y, z), a, (xx, yy, zz), x,

WITH t AS (SELECT 'a, b, c (x, y, z), a, (xx, yy, zz), x,' col1 
         FROM dual)
SELECT t.col1
 , REGEXP_REPLACE(t.col1, '(\(.*?\))|,', '\1') new_col
FROM t

Output : a b c (x, y, z) a (xx, yy, zz) x

But i want to make opposite of that. Just remove this character , from inside () and remain outside.

Output : a, b, c (x y z), a, (xx yy zz), x,

3 Answers
Related