Skip to content

Commit

Permalink
Corrected group name error
Browse files Browse the repository at this point in the history
  • Loading branch information
Ron Petrusha committed Jun 13, 2019
1 parent 12dc408 commit 3666ffd
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Grouping constructs delineate the subexpressions of a regular expression and cap

where *name1* is the current group (optional), *name2* is a previously defined group, and *subexpression* is any valid regular expression pattern. The balancing group definition deletes the definition of *name2* and stores the interval between *name2* and *name1* in *name1*. If no *name2* group is defined, the match backtracks. Because deleting the last definition of *name2* reveals the previous definition of *name2*, this construct lets you use the stack of captures for group *name2* as a counter for keeping track of nested constructs such as parentheses or opening and closing brackets.

The balancing group definition uses *name2* as a stack. The beginning character of each nested construct is placed in the group and in its <xref:System.Text.RegularExpressions.Group.Captures%2A?displayProperty=nameWithType> collection. When the closing character is matched, its corresponding opening character is removed from the group, and the <xref:System.Text.RegularExpressions.Group.Captures%2A> collection is decreased by one. After the opening and closing characters of all nested constructs have been matched, *name1* is empty.
The balancing group definition uses *name2* as a stack. The beginning character of each nested construct is placed in the group and in its <xref:System.Text.RegularExpressions.Group.Captures%2A?displayProperty=nameWithType> collection. When the closing character is matched, its corresponding opening character is removed from the group, and the <xref:System.Text.RegularExpressions.Group.Captures%2A> collection is decreased by one. After the opening and closing characters of all nested constructs have been matched, *name2* is empty.

> [!NOTE]
> After you modify the regular expression in the following example to use the appropriate opening and closing character of a nested construct, you can use it to handle most nested constructs, such as mathematical expressions or lines of program code that include multiple nested method calls.
Expand Down

0 comments on commit 3666ffd

Please sign in to comment.