The packet construct allows you to capture sub-expression groups and increase the efficiency of regular expressions with non-capture predictions and post-renovations. The following table describes the regular expression packet construct.
Packet construct notes () capture matching sub-strings (or non-capture groups; see ExplicitCapture options in the regular expression options) for more information. Use () capture to start automatically numbered from 1 according to the order of the left bracket. The first capture of capture element numbered zero is the text that matches the entire regular expression pattern. (? ) Capture the matching substring to a group name or number name. A string for NAME cannot contain any punctuation, and cannot begin with a number. You can use single-quoted replacement angle brackets, such as (? 'Name'). (? ) Balance Group Definition. Delete the definition of previously defined Name2 groups and store the interval between the previously defined Name2 group and the current group in the Name1 group. If the NAME2 group is not defined, the match will be back. Since the last definition of the deletion of Name2 displays the previous definition of Name2, the configuration allows the Name2 group of capture stacks to be used as a counter to track nested structures (such as parentheses). In this configuration, NAME1 is optional. You can use single-quoted replacement angle brackets, such as (? 'Name1-Name2'). (?:) Non-capture group. (• IMNSX-IMNSX:) Apply or disables the options specified in the sub-expression. For example, (? I-S:) will open uncountment and disable a single line mode. For more information, see the regular expression option. (? =) Zero width is predicting the first line assertion. Conveuing only when the sub-expression matches the right side of this location. For example, / w (? = / D) matches the word followed by the number without matching the number. This construct does not retrore. (?!) Zero width is negative forecasts first line assertion. You can continue to match only if the sub-expression does not match the right side of this location. For example, / b (?! Un) / w / b matches the word not starting with UNN. (? <=) Zero width is reviewing the assertion. Conveuing only when the sub-expression matches the left side of this location. For example, (? <= 19) 99 matches an example of 99 followed by the 19. This construct does not retrore. (? ) Non-retractable expression (also known as "greedy" sub-expression). The sub-expression is only completely matched once, and then participate in the backtrack. (That is, the sub-expression is only matched with a string that can be individually matched by the sub-expression.)
Named capture is numbered in order according to the left to right of the left bracket (similar to non-naming capture), but starts numbered naming capture after counting all non-nap capture. For example, mode ((? abc) / d )? (? XYZ) (. *) Generates the following capture group by numbered and name. (The first capture number "always refers to the entire mode).
No. Name Mode 00 ((? ABC) / D )? (? XYZ) (. *) 11 ((? ABC) / D ) 22 (default Name) (. *) 31 (? ABC) 42 (? xyz)
See
Regular expression language elements