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