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
posts - 14, comments - 26, trackbacks - 0, articles - 0

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

Posted on 2006-02-07 14:10 TOX 阅读(636) 评论(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*$");
  }