Match Email : Match Email « Regular Expressions « VB.Net Tutorial






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
a@nowhere.com   True
a@doe@mybad.com   False








20.2.Match Email
20.2.1.Match Email
20.2.2.Determines whether input format is valid for an e-mail address.