📜  验证电子邮件地址 - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:59.278000             🧑  作者: Mango

代码示例3
public bool IsValid(string emailaddress)
{
    private const string EmailRegEx = @"^[\w!#$%&'*+\-/=?\^_`{|}~]+(\.[\w!#$%&'*+\-/=?\^_`{|}~]+)*"
         + "@"
         + @"((([\w]+([-\w]*[\w]+)*\.)+[a-zA-Z]+)|"
         + @"((([01]?[0-9]{1,2}|2[0-4][0-9]|25[0-5]).){3}[01]?[0-9]{1,2}|2[0-4][0-9]|25[0-5]))\z";
    return new Regex(EmailRegEx, RegexOptions.None).Match(emailaddress).Success;
}