|
84 | 84 |
|
85 | 85 | For each match, the <xref:System.Text.RegularExpressions.GroupCollection> contains three <xref:System.Text.RegularExpressions.Group> objects. The first object contains the string that matches the entire regular expression. The second object, which represents the first captured group, contains the product name. The third object, which represents the second captured group, contains the trademark or registered trademark symbol.
|
86 | 86 |
|
87 |
| - [!code-csharp[System.Text.RegularExpressions.GroupCollection#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.RegularExpressions.GroupCollection/cs/Example1.cs#1)] |
88 |
| - [!code-vb[System.Text.RegularExpressions.GroupCollection#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.RegularExpressions.GroupCollection/vb/Example1.vb#1)] |
89 |
| - |
| 87 | + [!code-csharp[System.Text.RegularExpressions.GroupCollection#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.RegularExpressions.GroupCollection/cs/Example1.cs#1)] |
| 88 | + [!code-vb[System.Text.RegularExpressions.GroupCollection#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.RegularExpressions.GroupCollection/vb/Example1.vb#1)] |
| 89 | + |
90 | 90 | ]]></format>
|
91 | 91 | </remarks>
|
92 | 92 | <altmember cref="T:System.Text.RegularExpressions.Group" />
|
|
184 | 184 | ## Examples
|
185 | 185 | The following example extracts each word from a sentence and captures it in a capturing group, The <xref:System.Text.RegularExpressions.GroupCollection.CopyTo%2A> method is then used to copy the elements in each match's <xref:System.Text.RegularExpressions.GroupCollection> object to an array that contains the capturing groups from all matches. The individual captured words are then displayed to the console.
|
186 | 186 |
|
187 |
| - [!code-csharp[System.Text.RegularExpressions.GroupCollection.CopyTo#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.text.regularexpressions.groupcollection.copyto/cs/copyto1.cs#1)] |
188 |
| - [!code-vb[System.Text.RegularExpressions.GroupCollection.CopyTo#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.text.regularexpressions.groupcollection.copyto/vb/copyto1.vb#1)] |
| 187 | + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.text.regularexpressions.groupcollection.copyto/cs/copyto1.cs" interactive="try-dotnet" id="Snippet1"::: |
| 188 | + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.text.regularexpressions.groupcollection.copyto/vb/copyto1.vb" id="Snippet1"::: |
189 | 189 |
|
190 | 190 | The regular expression is defined as follows:
|
191 | 191 |
|
|
536 | 536 | |`(\w)`|This is the second capturing group.|
|
537 | 537 | |`\k`|Match the string captured by the second capturing group.|
|
538 | 538 |
|
539 |
| - [!code-csharp[System.Text.RegularExpressions.GroupCollection.Item#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.text.regularexpressions.groupcollection.item/cs/item3.cs#2)] |
540 |
| - [!code-vb[System.Text.RegularExpressions.GroupCollection.Item#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.text.regularexpressions.groupcollection.item/vb/item3.vb#2)] |
| 539 | + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.text.regularexpressions.groupcollection.item/cs/item3.cs" interactive="try-dotnet" id="Snippet2"::: |
| 540 | + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.text.regularexpressions.groupcollection.item/vb/item3.vb" id="Snippet2"::: |
541 | 541 |
|
542 | 542 | ]]></format>
|
543 | 543 | </remarks>
|
|
608 | 608 | |`(?<numbers>\d+)*`|Match one or more occurrence of a decimal digit. Name this the `numbers` capturing group. Match this pattern either zero or one time.|
|
609 | 609 | |`(?<letter>\w)`|Match a single word character. Name this the `letter` capturing group.|
|
610 | 610 | |`\k<letter>`|Match the string captured by the `letter` capturing group.|
|
611 |
| - |
612 |
| - [!code-csharp[System.Text.RegularExpressions.GroupCollection.Item#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.text.regularexpressions.groupcollection.item/cs/item2.cs#1)] |
613 |
| - [!code-vb[System.Text.RegularExpressions.GroupCollection.Item#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.text.regularexpressions.groupcollection.item/vb/item2.vb#1)] |
| 611 | + |
| 612 | + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.text.regularexpressions.groupcollection.item/cs/item2.cs" interactive="try-dotnet" id="Snippet1"::: |
| 613 | + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.text.regularexpressions.groupcollection.item/vb/item2.vb" id="Snippet1"::: |
614 | 614 |
|
615 | 615 | ]]></format>
|
616 | 616 | </remarks>
|
|
0 commit comments