c#项目中的正则判断

    技术2022-05-11  2

    //判断会员卡等级名称合法性质     public bool IsName(string strName)     {         string strValidRealPattern = "^[A-Za-z0-9/u4e00-/u9fa5]+$";         Regex objNumberPattern = new  Regex(strValidRealPattern);         return objNumberPattern.IsMatch(strName);     }     //判断生日赠票数字的合法性质     public bool IsNumber(string strNumber)     {         string strValidRealPattern = @"^[1-9]+[0-9]*$";         Regex objNumberPattern = new Regex(strValidRealPattern);         return objNumberPattern.IsMatch(strNumber);     }     //判断金额数字的合法性质     public bool CIsNumber(string strNumber)     {         string strValidRealPattern = @"^/d+/.?(/d+)*$";         Regex objNumberPattern = new Regex(strValidRealPattern);         return objNumberPattern.IsMatch(strNumber);     }     //判断积分数字的合法性质     public bool JIsNumber(string strNumber)     {         string strValidRealPattern = @"^[1-9]+/.?(/d+)*$";         Regex objNumberPattern = new Regex(strValidRealPattern);         return objNumberPattern.IsMatch(strNumber);     }     //判断则率数字的合法性质     public bool XIsNumber(string strNumber)     {         string strValidRealPattern = @"^(1(/.0+)?|(0/./d*[1-9]/d*))$";         Regex objNumberPattern = new Regex(strValidRealPattern);         return objNumberPattern.IsMatch(strNumber);     }

    最新回复(0)