Share via


Assert.MatchesRegex Method

Definition

Overloads

MatchesRegex(String, String, String)

Tests whether the specified string MatchesRegex a regular expression and throws an exception if the string does not match the expression.

MatchesRegex(Regex, String, String)

Tests whether the specified string MatchesRegex a regular expression and throws an exception if the string does not match the expression.

MatchesRegex(String, String, String)

Source:
Assert.Matches.cs

Tests whether the specified string MatchesRegex a regular expression and throws an exception if the string does not match the expression.

public static void MatchesRegex(string? pattern, string? value, string message = "");
static member MatchesRegex : string * string * string -> unit
Public Shared Sub MatchesRegex (pattern As String, value As String, Optional message As String = "")

Parameters

pattern
String

The regular expression that value is expected to match.

value
String

The string that is expected to match pattern.

message
String

The message to include in the exception when value does not match pattern. The message is shown in test results.

Exceptions

value is null, or pattern is null, or value does not match pattern.

Applies to

MatchesRegex(Regex, String, String)

Source:
Assert.Matches.cs

Tests whether the specified string MatchesRegex a regular expression and throws an exception if the string does not match the expression.

public static void MatchesRegex(System.Text.RegularExpressions.Regex? pattern, string? value, string message = "");
static member MatchesRegex : System.Text.RegularExpressions.Regex * string * string -> unit
Public Shared Sub MatchesRegex (pattern As Regex, value As String, Optional message As String = "")

Parameters

pattern
Regex

The regular expression that value is expected to match.

value
String

The string that is expected to match pattern.

message
String

The message to include in the exception when value does not match pattern. The message is shown in test results.

Exceptions

value is null, or pattern is null, or value does not match pattern.

Applies to