Represents the set of captures made by a single capturing group.
Assembly: System (in System.dll)
Gets the number of substrings captured by the group.
Gets a value that indicates whether the collection is read only.
Gets a value that indicates whether access to the collection is synchronized (thread-safe).
Gets an individual member of the collection.
Gets an object that can be used to synchronize access to the collection.
Copies all the elements of the collection to the given array beginning at the given index.
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.)
Provides an enumerator that iterates through the collection.
Serves as the default hash function. (Inherited from Object.)
Returns a string that represents the current object.(Inherited from Object.)
Overloaded. Enables parallelization of a query.(Defined by ParallelEnumerable.)
The collection is immutable (read-only) and has no public constructor. The Capture objects.object contains one or more
Instances of theclass are returned by the following properties:
The Group.Captures property. Each member of the collection represents a substring captured by a capturing group. If a quantifier is not applied to a capturing group, the includes a single Capture object that represents the same captured substring as the Group object. If a quantifier is applied to a capturing group, the includes one Capture object for each captured substring, and the Group object provides information only about the last captured substring.
The Match.Captures property. In this case, the collection consists of a single Capture object that provides information about the match as a whole. That is, the object provides the same information as the Match object.
To iterate through the members of the collection, you should use the collection iteration construct provided by your language (such as foreach in C# and For Each…Next in Visual Basic) instead of retrieving the enumerator that is returned by the GetEnumerator method.
The following example compares the Capture objects in the object returned by the Group.Captures and Match.Captures properties. It also compares Group objects with the Capture objects in the returned by the Group.Captures property. The example uses the following two regular expressions to find matches in a single input string:
This regular expression pattern identifies a word that consists of one or more word characters, followed by either one or two non-word characters such as white space or punctuation. The regular expression does not include any capturing groups. The output from the example shows that both the Match object and the objects returned by the Group.Captures and Match.Captures properties contain information about the same match.
This regular expression pattern identifies the words in a sentence. The pattern defines a single capturing group that consists of one or more word characters followed by one or two non-word characters. The regular expression pattern uses the + quantifier to match one or more occurrences of this group. The output from this example shows that the Match object and the object returned by the Match.Captures property contain information about the same match. The second Group object, which corresponds to the only capturing group in the regular expression, identifies only the last captured string, whereas the object returned by the first capturing group's Group.Captures property includes all captured substrings.
Available since 4.5
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.