Represents the results from a single successful subexpression capture.
Assembly: System (in System.dll)
Determines whether the specified object is equal to the current object.(Inherited from Object.)
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)
Serves as the default hash function. (Inherited from Object.)
If you do not apply a to a capturing group, the Group.Captures property returns a CaptureCollection with a single object that provides information about the same capture as the Group object. If you do apply a quantifier to a capturing group, the Group.Index, Group.Length, and Group.Value properties provide information only about the last captured group, whereas the objects in the CaptureCollection provide information about all subexpression captures. The example provides an illustration.
The following example defines a regular expression that matches sentences that contain no punctuation except for a period (".").
The regular expression pattern ((\w+)[\s.])+ is defined as shown in the following table. Note that in this regular expression, a quantifier (+) is applied to the entire regular expression.
Match one or more word characters. This is the second capturing group.
Match a white-space character or period (".").
Match one or more word characters followed by a white-space character or period ("."). This is the first capturing group.
Match one or more occurrences of a word character or characters followed by a white-space character or period (".").
In this example, the input string consists of two sentences. As the output shows, the first sentence consists of only one word, so the CaptureCollection object has a single object that represents the same capture as the Group object. The second sentence consists of multiple words, so the Group objects only contain information about the last matched subexpression. Group 1, which represents the first capture, contains the last word in the sentence that has a closing period. Group 2, which represents the second capture, contains the last word in the sentence. However, the objects in the group's CaptureCollection object capture each subexpression match. The objects in the first capturing group's collection of captures contain information about each captured word and white-space character or period. The objects in the second capturing group's collection of captures contain information about each captured word.
Available since 8
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Available since 8.1
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.