Validating e-mail with regular expression VB.Net

后端 未结 6 1759
没有蜡笔的小新
没有蜡笔的小新 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:22

    Pick your favorite regex from my article on matching email addresses with a regex, and plug it into this Visual Basic code:

    If Regex.IsMatch(SubjectString, "regex") Then
        Error = False
    Else
        Error = True
    End If
    

    The best regex to match an email address is a controversial topic that I don't want to get into here. My article discusses the issues that you should be aware of when picking a regex. The regex in Joel Coehoorn's answer is definitely not a good one.

提交回复
热议问题