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!

Use regexp_replace to blank-out or remove the parentheses and words in it?

843098Feb 28 2011 — edited Feb 28 2011
If I need to remove parenthese and wordings within it from the input data, what should be the pattern I used in the regexp_replace?

Again, it works on (), and {} but not [], how should I write in the pattern of regexp_replace?

select 'What a good day for (YOU [ME] and {HIM}) and others',
REGEXP_REPLACE('What a good day for (YOU [ME] and {HIM}) and others', '\([^()]*\)', '')
from dual
SQL> What a good day for and others

select 'What a good day for (YOU [ME] and {HIM}) and others',
REGEXP_REPLACE('What a good day for (YOU [ME] and {HIM}) and others', '\{[^{}]*\}', '')
from dual
SQL> What a good day for (YOU [ME] and ) and others

*** NOT WORKING FOR [ ] below ***
select 'What a good day for (YOU [ME] and {HIM}) and others',
REGEXP_REPLACE('What a good day for (YOU [ME] and {HIM}) and others', '\[[^[]]*\]', '')
from dual
SQL> What a good day for (YOU [ME] and {HIM}) and others

Can anyone help??

Appreciate,the answer you provide.

Fiona
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 28 2011
Added on Feb 28 2011
14 comments
8,677 views