This is Oracle's description of the backreference of the regular expression.
From the definition, we can see that when a substring is included in the matching expression in the form of (), it can be followed \? . \ 1 corresponds to the first (), \ 2 corresponds to the second...
The introduction of reverse references makes the matching function of regular expressions more powerful. This article introduces two applications in oracle regular expressions.
Regexp_like
Regexp_like ('100', '^ ([0-9]) (\ d) \ 1 \ 1 \ 2 (\ d) \ 3 $ ')
In the above example, \ 1 indicates the first ([0-9]) in the matching expression. This expression must be used to determine whether the numbers 3rd and 4 in the string are the same as the numbers 1st, not just matching [0-9]
Regexp_replace
Regexp_replace ('20140901', '^ (.)', '\ 1 \ 2 \ 5 ')
Here, replace the part that matches the matching expression with the content that satisfies \ 1 \ 2 \ 5, that is, the first (.) Second (.) and the fifth (.)
Guess what will be returned here?
Due to ^ (.) (.) (.) (.) (.) (.) matches the first six digits of the string, so the result is \ 1 \ 2 \ 5 | the part after the first six digits, that is, 6th