My opinion on regular expressions-back reference

Source: Internet
Author: User

When you specify a subexpression with parentheses, the text that matches the subexpression (that is, what this grouping captures) can be further processed in an expression or other program.

By default, each grouping automatically has a group number, with the rule: left-to-right, with the left parenthesis of the group as the flag, the group number for the first occurrence is 1, the second is 2, and so on.

A back reference is used to repeat the search for text that precedes a grouping match.

category Code/Syntax Description
Capture (exp) Match exp, and capture text into an automatically named group
(? <name>exp) Match exp, and capture the text to a group named name, or you can write (? ') Name ' exp ')
(?: EXP) Matches exp, does not capture matching text, and does not assign group numbers to this group
0 Wide Assertion (? =exp) Match the position of the exp front
(? <=exp) Match the position after exp
(?! Exp Match the position followed by the exp.
(? <!exp) Match a location that is not previously exp
Comments (? #comment) This type of grouping does not have any effect on the processing of regular expressions, and is used to provide comments for people to read

1.1 Capture

1.2 0 Wide Assertion

1.3 Notes

My opinion on regular expressions-back reference

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.