Represents the results from a single capturing group.
Assembly: System (in System.dll)
Gets a collection of all the captures matched by the capturing group, in innermost-leftmost-first order (or innermost-rightmost-first order if the regular expression is modified with the RegexOptions.RightToLeft option). The collection may have zero or more items.
The position in the original string where the first character of the captured substring is found.(Inherited from Capture.)
Gets the length of the captured substring.(Inherited from Capture.)
Gets a value indicating whether the match is successful.
Gets the captured substring from the input string.(Inherited from Capture.)
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.)
Returns a Group object equivalent to the one supplied that is safe to share between multiple threads.
A capturing group can capture zero, one, or more strings in a single match because of quantifiers. (For more information, see Quantifiers in Regular Expressions.) All the substrings matched by a single capturing group are available from the Group.Captures property. Information about the last substring captured can be accessed directly from the Value and Index properties. (That is, the instance is equivalent to the last item of the collection returned by the Captures property, which reflects the last capture made by the capturing group.)
An example helps to clarify this relationship between a System.Text.RegularExpressions.CaptureCollection that is returned by the Captures property. The regular expression pattern (\b(\w+?)[,:;]?\s?)+[?.!] matches entire sentences. The regular expression is defined as shown in the following table.object and the
Begin the match at a word boundary.
Match one or more word characters, but as few characters as possible. This is the second (inner) capturing group. (The first capturing group includes the \b language element.)
Match zero or one occurrence of a comma, colon, or semicolon.
Match zero or one occurrence of a white-space character.
Match the pattern consisting of a word boundary, one or more word characters, a punctuation symbol, and a white-space character one or more times. This is the first capturing group.
Match any occurrence of a period, question mark, or exclamation point.
In this regular expression pattern, the subpattern (\w+?) is designed to match multiple words within a sentence. However, the value of the object represents only the last match that (\w+?) captures, whereas the Captures property returns a CaptureCollection that represents all captured text. As the output shows, the CaptureCollection for the second capturing group contains four objects. The last of these corresponds to the object.
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.