Validator.Regex Method

Defines a validation test that tests a value against a pattern specified as a regular expression.

Namespace:  System.Web.WebPages
Assembly:  System.Web.WebPages (in System.Web.WebPages.dll)

Syntax

'Declaration
Public Shared Function Regex ( _
    pattern As String, _
    errorMessage As String _
) As IValidator
'Usage
Dim pattern As String 
Dim errorMessage As String 
Dim returnValue As IValidator 

returnValue = Validator.Regex(pattern, _
    errorMessage)
public static IValidator Regex(
    string pattern,
    string errorMessage
)
public:
static IValidator^ Regex(
    String^ pattern, 
    String^ errorMessage
)
static member Regex : 
        pattern:string * 
        errorMessage:string -> IValidator
public static function Regex(
    pattern : String, 
    errorMessage : String
) : IValidator

Parameters

  • pattern
    Type: System.String
    The regular expression to use to test the user input.
  • errorMessage
    Type: System.String
    The error message to display if validation fails.

Return Value

Type: System.Web.WebPages.IValidator
The validation test.

Remarks

This test lets you define validation tests for values that are not covered by existing validation tests.

See Also

Reference

Validator Class

System.Web.WebPages Namespace