Thursday, August 28, 2008

Validating Email id using Regular Expression in vb.net

Dim m As System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex("^((?>[a-zA-Z\d!#$%&'*+\-/=?^_`{|}~]" & _

"+\x20*|""((?=[\x01-\x7f])" & _

"[^""\\]|\\[\x01-\x7f])*""\x20*)*(?<))?((?!\.)" & _ "(?>\.?[a-zA-Z\d!#$%&'*+\-/=?^_`{|}~]+)+|""((?=[\x01-\x7f])[^""\\]" & _

"|\\[\x01-\x7f])*"")@(((?!-)[a-zA-Z\d\-]+(? & _

"{4}|[a-zA-Z\d\-]*[a-zA-Z\d]:((?=[\x01-\x7f])[^\\\[\]]|\\[\x01-\x7f])+)\])(?(angle)>)$")

Dim isMatch As Boolean = m.IsMatch(txtBrokerEmail.Text) 'INPUT

MsgBox(isMatch.ToString())


No comments: