Regex.IsMatch
Imports System.Text.RegularExpressions
Public Class Tester
Public Shared Sub Main
Dim testString As String
Dim emailPattern As String = _
"^([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@" & _
"([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$"
testString = "a@nowhere.com"
Console.WriteLine(testString & Space(3) & _
Regex.IsMatch(testString, emailPattern))
testString = "a@doe@mybad.com"
Console.WriteLine(testString & Space(3) & _
Regex.IsMatch(testString, emailPattern))
End Sub
End Class
Related examples in the same category