Regular advanced syntax, advanced syntax

Source: Internet
Author: User

Regular advanced syntax, advanced syntax

Note that some compilers do not support advanced syntax

1. Select character group reverse reference

 

Group and capture

The capture group can be numbered from left to right by calculating its parentheses. For example, in expression (A) (B (C), there are four such groups:

1

(A) (B (C )))

2

\

3

(B (C ))

4

(C)

Group zero always represents the entire expression.

The reason for naming the capture group is that each sub-sequence of the input sequence that matches these groups is saved in the match. The captured sub-sequence can be used in the expression through Back reference later, or it can be obtained from the matcher after the matching operation is completed.

The capture input associated with the group is always the child sequence that is most recently matched with the group. If the group is calculated again due to quantification, the previously captured value (if any) will be retained when the second calculation fails. For example, convert the string "aba" with the expression (a (B )?) + If it matches, the second group is set to "B ". At the beginning of each match, all captured input is discarded.

Take (?) The group at the beginning is pureNon-capturingGroup, which does not capture text or count the combined counts.

Reverse reference:

 

Non-capturing group:

 

 

 

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger. Http://blog.csdn.net/qq_37493888/article/details/79211703

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.