Share via


Capture Class

[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
Public property Index The position in the original string where the first character of the captured substring is found.
Public property Length Gets the length of the captured substring.
Public property Value Gets the captured substring from the input string.

Top

Methods

  Name Description
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method 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.

See Also

Reference

System.Text.RegularExpressions Namespace