Regex Email validation

后端 未结 30 1222
北海茫月
北海茫月 2020-11-22 12:16

I use this

@\"^([\\w\\.\\-]+)@([\\w\\-]+)((\\.(\\w){2,3})+)$\"

regexp to validate the email

([\\w\\.\\-]+) - this is f

30条回答
  •  没有蜡笔的小新
    2020-11-22 12:32

    I've been using the Regex.IsMatch().

    First of all you need to add the next statement:

    using System.Text.RegularExpressions;
    

    Then the method looks like:

    private bool EmailValidation(string pEmail)
    {
                     return Regex.IsMatch(pEmail,
                     @"^(?("")("".+?(?

    It's a private method because of my logic but you can put the method as static in another Layer such as "Utilities" and call it from where you need.

提交回复
热议问题