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!

Remove Square Braces Enclosed Substring(s)

Sirish ReddyDec 18 2019 — edited Dec 21 2019

I am a Java developer and need to write a query to remove any text that is present between the square braces.

For example, if my input is

[DATE] set for [SET] conference. Further hearing to be set.

the output should be

[] set for [] conference. Further hearing to be set.

I have come up with the following regular expression but not getting the desired output

select regexp_replace('[DATE] set for [SET] conference. Further hearing to be set.','\[[^()]*\]', '[from dual

Everything between the first open square and the last closing square is getting trimmed.

[] conference. Further hearing to be set.

I appreciate any help on resolving this issue.

Thanks.

This post has been answered by mathguy on Dec 18 2019
Jump to Answer
Comments
Post Details
Added on Dec 18 2019
4 comments
1,891 views