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!

Removing all duplicates with regexp

MWaseemAug 28 2020 — edited Aug 28 2020

The below query can remove the consecutive duplicates. (to remove duplicates from comma separated list)

select regexp_replace('A,A,B,A','([^,]+)(,\1)*(,|$)', '\1\3') from dual

Result is A,B,A.

can i remove all the duplicates with regexp_replace from a string i.e .

source string = A,A,B,C,C,A,A,C   Result should be = A,B,C

Comments
Post Details
Added on Aug 28 2020
5 comments
5,124 views