Return to Snippet

Revision: 8102
at September 2, 2008 11:41 by Anthony


Initial Code
''' <summary>
''' Determines whether provided email address is properly formatted.
''' </summary>
''' <param name="s"></param>
''' <returns></returns>
''' <remarks></remarks>
Private Function IsValidEmailFormat(ByVal s As String) As Boolean
    Dim result As Boolean = False

    If Not String.IsNullOrEmpty(s) Then

        '^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$
        Dim pattern As String = My.Settings.Email_Validation_Pattern

        Dim match As RegularExpressions.Match = RegularExpressions.Regex.Match(s, pattern)
        result = match.Success
    End If

    Return result
End Function

Initial URL

                                

Initial Description
Uses a regular expression to validate a string as a validly formatted email address.

Initial Title
Email Address Format Validation

Initial Tags
email, validation

Initial Language
VB.NET