match class : Groups() method

Description

Get a list of all substrings that match the regular expression group.

Syntax

matchInstance.Groups()

Arguments

None

Return value

ClassDescription
list{string}A list of all substrings that match the regular expression group.

Sample code

1:

regex pattern = new regex("(\d)(\d)");

2:

match firstMatch= pattern.MatchM("ww1245cc66"); // It matches to "12".

3:

int count = firstMatch.GroupCount; // The GroupCount is 3. "12", "1", and "2"

4:

list{string} resultList = firstMatch.Groups();

5:

string resultStr = resultList.GetAt(0); // "12"

6:

resultStr = resultList.GetAt(1); // "1"

7:

resultStr = resultList.GetAt(2); // "2"

Notes

None.

Links for reference

Copyright © Cooker All rights reserved.