标签:nbsp egerp double blog erp eal string regex match
1 /// <summary> 2 /// 判断字符串是否是int/double 3 /// </summary> 4 public static bool IsIntOrDouble(string strNumber) 5 { 6 Regex objNotNumberPattern = new Regex("[^0-9.-]"); 7 Regex objTwoDotPattern = new Regex("[0-9]*[.][0-9]*[.][0-9]*"); 8 Regex objTwoMinusPattern = new Regex("[0-9]*[-][0-9]*[-][0-9]*"); 9 const string strValidRealPattern = "^([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]+$"; 10 const string strValidIntegerPattern = "^([-]|[0-9])[0-9]*$"; 11 Regex objNumberPattern = new Regex("(" + strValidRealPattern + ")|(" + strValidIntegerPattern + ")"); 12 return !objNotNumberPattern.IsMatch(strNumber) && 13 !objTwoDotPattern.IsMatch(strNumber) && 14 !objTwoMinusPattern.IsMatch(strNumber) && 15 objNumberPattern.IsMatch(strNumber); 16 }
标签:nbsp egerp double blog erp eal string regex match
原文地址:http://www.cnblogs.com/zhang625161495/p/6216998.html