C# 正则表达式判断是否是数字、是否含有中文、是否是数字字母组合

//判断输入是否包含中文  不管你有没有输入英文,只要包含中文,就返回 true
   public static bool HasChinese(string content)
   {
       //判断是不是中文
       string regexstr = @"[u4e00-u9fa5]";
 
       if (Regex.IsMatch(content, regexstr))
       {
           Log("HasChinese");
           return true;
       }
       else
       {
           Log("Has Not Chinese");
           return false;
       }
   }
 
   //判断是不是数字
   public static bool isInterger(string str)
   {
       if (str == "")
       {
           return false;
       }
       else
       {
           foreach (char c in str)
           {
               if (char.IsNumber(c))
               {
                   continue;
               }
               else
               {
                   return false;
               }
           }
       }
       return true;
 
   }
 
   //只允许数字或字母的判断
   public static bool isIntergerOrLetter(string content)
   {
       System.Text.RegularExpressions.Regex reg1 = new System.Text.RegularExpressions.Regex(@"^[A-Za-z0-9]+$");
       return reg1.IsMatch(content);
   }
原文地址:https://www.cnblogs.com/joeylee/p/3892081.html