'
' Validates an email address using regex.
'
Public Function IsEmailValid(ByVal sEmail As String) As Boolean
Dim sEmailRegex As String = "^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"
Dim oRegex As System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex(sEmailRegex)
If Not (oRegex.IsMatch(sEmail)) Then
Return False
Else
Return True
End If
End Function
|