Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework
Regex Class
Regex Methods
IsMatch Method
 IsMatch Method (String, String)
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
Regex..::.IsMatch Method (String, String)

Indicates whether the regular expression finds a match in the input string using the regular expression specified in the pattern parameter.

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

Visual Basic (Declaration)
Public Shared Function IsMatch ( _
    input As String, _
    pattern As String _
) As Boolean
Visual Basic (Usage)
Dim input As String
Dim pattern As String
Dim returnValue As Boolean

returnValue = Regex.IsMatch(input, _
    pattern)
C#
public static bool IsMatch(
    string input,
    string pattern
)
Visual C++
public:
static bool IsMatch(
    String^ input, 
    String^ pattern
)
J#
public static boolean IsMatch(
    String input,
    String pattern
)
JScript
public static function IsMatch(
    input : String, 
    pattern : String
) : boolean

Parameters

input
Type: System..::.String

The string to search for a match.

pattern
Type: System..::.String

The regular expression pattern to match.

Return Value

Type: System..::.Boolean

true if the regular expression finds a match; otherwise, false.

ExceptionCondition
ArgumentNullException

input is nullNothingnullptra null reference (Nothing in Visual Basic).

-or-

pattern is nullNothingnullptra null reference (Nothing in Visual Basic).

The two static IsMatch methods are equivalent to constructing a Regex object with the specified regular expression pattern and calling the instance method IsMatch. The static methods are provided to allow an isolated, single use of a regular expression without explicitly creating a Regex object.

The pattern parameter consists of various regular expression language elements that symbolically describe the string to match. For more information about regular expressions, see .NET Framework Regular Expressions and Regular Expression Language Elements.

Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0 SP1, 3.0, 2.0 SP1, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

XNA Framework

Supported in: 1.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content      
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker