C#正则表达式验证数字

C#正则表达式验证数字

static bool IsNumeric(string str)

{

System.Text.RegularExpressions.Regex reg1

= new System.Text.RegularExpressions.Regex(@"^[-]?\d+[.]?\d*$");

return reg1.IsMatch(str);

}