REGEXP_REPLACE backlink

I have looked at the Oracle documentation regarding the function REGEXP_REPLACE

, but it doesn't work as expected

This is what I got:


My goal: character concatenation for each set of contiguous numbers

My input:

(1101 + 1102) * 1103 + 1104 + 1105

      

Expected Result:

(T1101 + T1102) * T1103 + T1104 + T1105

      

Code:

SELECT
  REGEXP_REPLACE('(1101 + 1102) * 1103 + 1104 + 1105',
                 '[0-9]+',
                 'T\1') "REZ"
  FROM DUAL;

      

Result:

(T\1 + T\1) * T\1 + T\1 + T\1

      


I have searched a lot of Stack Overflow posts and they all seem to work in this scenario without any problem regarding \ 1

And tried different places to check the code: Tod for oracle, SqlPlus and another application, they all gave me the same results.

So, can anyone tell me what happened to my code?

Note:

I have no idea that my regex has any problems, checked earlier in another script in oracle and how it works. Also, matches were found, but the replacement part does not work.

Links to some Stack Overflow posts:

Ref1 , Ref2 , Ref3

Link to Oracle documentation:

REGEXP_REPLACE

+3


source to share


1 answer


\1

a backlink that looks for previous matched groups and groups can be captured by enclosing it in a parenthesis(...)

It should be



([0-9]+)

      

+4


source







All Articles