Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
Represents the results from a single successful subexpression capture.
Inheritance Hierarchy
System. . :: . .Object
System.Text.RegularExpressions..::..Capture
System.Text.RegularExpressions. . :: . .Group
Namespace: System.Text.RegularExpressions
Assembly: System.Text.RegularExpressions (in System.Text.RegularExpressions.dll)
Syntax
'Declaration
<SerializableAttribute> _
Public Class Capture
[SerializableAttribute]
public class Capture
[SerializableAttribute]
public ref class Capture
[<SerializableAttribute>]
type Capture = class end
public class Capture
The Capture type exposes the following members.
Properties
Name | Description | |
---|---|---|
![]() |
Index | The position in the original string where the first character of the captured substring is found. |
![]() |
Length | Gets the length of the captured substring. |
![]() |
Value | Gets the captured substring from the input string. |
Top
Methods
Name | Description | |
---|---|---|
![]() |
Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() |
GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() |
ToString | Retrieves the captured substring from the input string by calling the Value property. (Overrides Object. . :: . .ToString() () () ().) |
Top
Remarks
A Capture object is immutable and has no public constructor. Instances are returned through the CaptureCollection object, which is returned by the Match.Captures and Group..::..Captures properties. However, the Match.Captures property provides information about the same match as the Match object.
If you do not apply a quantifier to a capturing group, the Group..::..Captures property returns a CaptureCollection with a single Capture 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 Capture objects in the CaptureCollection provide information about all subexpression captures. The example provides an illustration.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.