Connect the dots

“Progress doesn't come from early risers – progress is made by lazy men looking for easier ways to do things.” - Robert Heinlein

导航

利用正则表达式判断一个字符串是否为数字

Posted on 2006-02-07 14:10  TOX  阅读(1014)  评论(0编辑  收藏  举报

 

  public static bool IsNumeric(string value)
  
{
   
return Regex.IsMatch(value, @"^[+-]?\d*[.]?\d*$");
  }


  
public static bool IsInt(string value)
  
{
   
return Regex.IsMatch(value, @"^[+-]?\d*$");
  }


  
public static bool IsUnsign(string value)
  
{
   
return Regex.IsMatch(value, @"^\d*[.]?\d*$");
  }