thanks Chris.!
the requests is to replace repeated string. the string pattern is [A-Z][0-9]5, for example:, string: '///2E/A12345/E53421$$@#/A123456*#/A123456**4E53421$$$$$@@!!!'
A12345 repeated 3 time, last two should be replaced. E53421 only has one, keep it.
expected result is: '///2E/A12345/E53421$$@#*#/6**4E53421$$$$$@@!!!'
for below regexp_repalce, I am not able to fully understand. below is my understanding based on the result not sure if this is correct.
for SUBSTR (STR, REGEXP_INSTR (STR, '[A-Z][0-9]{5}', 1,
1), the occurrence loops multiple times like REGEXP_INSTR (STR, '[A-Z][0-9]{5}', 1,
1) + 6, REGEXP_INSTR (STR, '[A-Z][0-9]{5}', 1,
2) + 6, REGEXP_INSTR (STR, '[A-Z][0-9]{5}', 1,
3) + 6 ...
then SUBSTR (STR, REGEXP_INSTR (STR, '[A-Z][0-9]{5}',
2, repeating the look.
please advice.
REGEXP_REPLACE (STR, SUBSTR (STR, REGEXP_INSTR (STR, '[A-Z][0-9]{5}', 1, RN), 6), '', REGEXP_INSTR (STR, '[A-Z][0-9]{5}', 1, RN) + 6)