Match Method (String)

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Searches the specified input string for the first occurrence of the regular expression specified in the Regex constructor.

Namespace:  System.Text.RegularExpressions
Assembly:  System.Text.RegularExpressions (in System.Text.RegularExpressions.dll)

Syntax

'Declaration
Public Function Match ( _
    input As String _
) As Match
public Match Match(
    string input
)
public:
Match^ Match(
    String^ input
)
member Match : 
        input:string -> Match 
public function Match(
    input : String
) : Match

Parameters

Return Value

Type: System.Text.RegularExpressions. . :: . .Match
An object that contains information about the match.

Remarks

The Match(String) method returns the first substring that matches a regular expression pattern in an input string.

You can determine whether the regular expression pattern has been found in the input string by checking the value of the returned Match object's Success property. If a match is found, the returned Match object's Value property contains the substring from input that matches the regular expression pattern. If no match is found, its value is String..::..Empty.

This method returns the first substring in input that matches the regular expression pattern. You can retrieve subsequent matches by repeatedly calling the returned Match object's Match..::..NextMatch method. You can also retrieve all matches in a single method call by calling the Regex..::..Matches(String) method.

.NET Framework Security

See Also

Reference

Regex Class

Match Overload

System.Text.RegularExpressions Namespace