求2个正则或方法,判断email 和 金额   \33,333 这种类型半夜了,懒得写,散分。一会回来直接copy。

解决方案 »

  1.   

    Email:
      <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="格式不正确" ContorlToValidate= "textbox1"
                ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
        另:输入的数字要输入千分号吗?可以带小数?
      

  2.   

    public static bool IsCurrency(string input)
            {
                if (input == null)
                {
                    return false;
                } 
     
            string pattern = @"^\" + ConstUtility.DOLLAR + @"(([0-9]{1,3}(,[0-9]{3})*?)|[0-9]+)(\.[0-9]{1,2})?$";
                 
                Match match = Regex.Match(input, pattern, RegexOptions.IgnoreCase);
     
                if (match.Success)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
     
     
       public static bool IsValidEmail(string input)
            {
                if (!IsNullOrEmpty(input))
                {
                    return Regex.IsMatch(input, @"^[a-zA-Z0-9-_\.]+@[a-zA-Z0-9-_]+([\.][a-zA-Z0-9-_]+)+$");
                }
                else
                {
                    return true;
                }
            }
    看看符合不符合