常用正则表达式 check

来源:互联网 发布:网络简介阅读分析答案 编辑:程序博客网 时间:2024/06/05 07:55
        private static Regex RegPhone = new Regex("^[0-9]+[-]?[0-9]+[-]?[0-9]{1}$");private static Regex RegNumber = new Regex("^[0-9]+{1}$");private static Regex RegNumberSign = new Regex("^[+-]?[0-9]+{1}$");private static Regex RegDecimal = new Regex("^[0-9]+[.]?[0-9]+{1}$");private static Regex RegDecimalSign = new Regex("^[+-]?[0-9]+[.]?[0-9]+{1}$"); //等价于^[+-]?\d+[.]?\d+$private static Regex RegEmail = new Regex("^[\\w-]+@[\\w-]+\\.(com|net|org|edu|mil|tv|biz|info){1}$");//w 英文字母或数字的字符串,和 [a-zA-Z0-9] 语法一样 private static Regex RegCHZN = new Regex("[\u4e00-\u9fa5]");//是否有中文


 一个例子:

 

#region 中文检测/// <summary>/// 检测是否有中文字符/// </summary>/// <param name="inputData"></param>/// <returns></returns>public static bool IsHasCHZN(string inputData){Match m = RegCHZN.Match(inputData);return m.Success;}#endregion