C#中判断输入数据是否为数字正则表达式

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
         {
         }
}

你可能感兴趣的:(C#中判断输入数据是否为数字正则表达式)