Friday, January 16, 2009

Email address validation with Vb.net and Regula Expression

Imports System.Text.RegularExpressions


Dim ValidateMail As String = "^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-z]{2,4}|[0-9]{1,3})(\]?)$"

Dim EmailAddress As String = "$mymail@domain.com$"

If Regex.IsMatch(EmailAddress, ValidateMail) Then
...
Else
...
End If

No comments: