Reverse reference in backreferenceOracle Regular Expression

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.