This is Oracle's description of the backreference of regular expressions
As you can see from the definition, a substring is included in the form of a matching expression, which can be referenced later in the form of \. \1 corresponds to the first (), \2 corresponds to the second ...
The introduction of reverse reference makes the matching function of regular expression become more powerful, and introduces two applications in Oracle regular function
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 digits, not just the [0-9]
Regexp_replace
Regexp_replace (' 1234567 ', ' ^ (.) (.) (.) (.) (.) (.) ', ' \1\2\5 ')
Here, replace the part in the matching expression with the content that satisfies the \1\2\5, that is, the first (.) The second (.) and fifth (.)
Guess what's coming back here.
Because ^ (.) (.) (.) (.) (.) (.) Matches the first 6 bits of the string, so the result is \1\2\5| | After the 6th part, that is 1257