使用正则表达式(判断字符串是否为数字)

using System.Text.RegularExpressions;
        
         private static bool IsNumeric(string itemValue) 
        {
            return (IsRegEx("^(-?[0-9]*[.]*[0-9]{0,3})$", itemValue));
         }

        private static bool IsRegEx(string regExValue, string itemValue) 
        {
            try 
            {
                 Regex regex = new System.Text.RegularExpressions.Regex(regExValue);
                if (regex.IsMatch(itemValue)) return true;
                else                          return false;
             }
            catch (Exception ) 
            {
                return false;
             }
            finally 
            {
             }
         }

 

详情 写道
http://student.csdn.net/space.php?uid=335625&do=blog&id=29872

 

你可能感兴趣的:(正则表达式)