/ Published in: VB.NET
Uses a regular expression to validate a string as a validly formatted email address.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
''' <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