This is the description of Oracle's backreference of regular expressions
As you can see from the definition, a substring is included in the form of () in the matching expression, and can be referenced in the form of \? later. \1 corresponds to the first (), \2 corresponds to the second ...
The introduction of reverse references makes the matching function of regular expressions more powerful and introduces two applications in Oracle regular functions
Regexp_like
Regexp_like (' 1211233 ', ' ^ ([0-9]) (\d) \1\1\2 (\d) \3$ ')
In this example, in the match expression, \1 represents the first ([0-9]), which determines whether the 3rd, 4 digits in the string are the same as the 1th bit, not just the match [0-9].
Regexp_replace
Regexp_replace (' 1234567 ', ' ^ (.) (.) (.) (.) (.) (.) ', ' \1\2\5 ')
Here, replace the part in the matching expression with the content that satisfies \1\2\5, the first (.) A second (.) and a fifth (.)
Guess what's going to come back here?
Because ^ (.) (.) (.) (.) (.) (.) Matches the first 6 bits of the string, so the result is \1\2\5| | After the 6th bit, that is, 1257