Validating e-mail with regular expression VB.Net

后端 未结 6 1762
没有蜡笔的小新
没有蜡笔的小新 2020-12-05 16:13

I\'m working on a small project in VB.Net where I get a input from a textbox, and need to verify that this is an e-email address.

I found this expression \"^[_a-z0-9

6条回答
  •  南笙
    南笙 (楼主)
    2020-12-05 16:45

    Possibly off-topic since it's not a regex solution, but you could just use some of the built in features of .NET 2.0:

    try
    {
       MailAddress email = new MailAddress(txtEmail.Text);
    }
    catch(FormatException fe)
    {
       // output error
    }
    

提交回复
热议问题