0

I going through a oracle code and found this code:

Query 1:

SELECT RTRIM (REGEXP_REPLACE ('ABC,CDE,ABC','([^,]*)(,\1)+($|,)','\1\3'),',') FROM DUAL;

Output 1:

ABC,CDE,ABC

Query 2:

SELECT RTRIM (REGEXP_REPLACE ('ABC,ABC,CDE','([^,]*)(,\1)+($|,)','\1\3'),',') FROM DUAL;

Output 2:

ABC,CDE

Query 3:

SELECT RTRIM (REGEXP_REPLACE ('ABC,ABC,CDE,CDE,ABC,CDE','([^,]*)(,\1)+($|,)','\1\3'),',') FROM DUAL;

Output 3:

ABC,CDE,ABC,CDE

though I know what this regexp_replace is doing but I need to understand what this regexp_replace is doing step by step and what it mean by each key word.I am able to find usage of individual syntax part but can't decipher it with combination.

Also if there is any website/book available to learn such complex usage of regexp_replace function, it would be great help.

lit
  • 10,936
  • 7
  • 49
  • 80

0 Answers0