在ASP.NET中有验证控件,如要验证电子邮箱的正则比达式如何写?

解决方案 »

  1.   

    bool IsValidEmail(string strIn)
    {
        // Return true if strIn is in valid e-mail format.
        return Regex.IsMatch(strIn, @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"); 
    }
      

  2.   

    \w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
      

  3.   

    如果是使用那个验证控件的话
    那个属性里面有现成的 表达式
    \w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
      

  4.   

    gamemast() 说的对了,但好像还不是很精确。我把后缀输为coom也是电子邮箱了,不知道是不是就有这个后缀的邮箱?
      

  5.   

    那个控件自带了信箱的啊<asp:RegularExpressionValidator id="RegularExpressionValidator1" runat="server" ErrorMessage="格式错误" ControlToValidate="Tb_Mail"
    ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
      

  6.   

    "^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"