Regex Email validation

后端 未结 30 1426
北海茫月
北海茫月 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:36

    STRING SEARCH USING REGEX METHOD IN C#

    How to validate an Email by Regular Expression?

    string EmailPattern = @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
    if (Regex.IsMatch(Email, EmailPattern, RegexOptions.IgnoreCase))
    {
        Console.WriteLine("Email: {0} is valid.", Email);
    }
    else
    {
        Console.WriteLine("Email: {0} is not valid.", Email);
    }
    

    Use Reference String.Regex() Method

提交回复
热议问题