1.判读是否为数字
System.Text.RegularExpressions.Regex reg1 = new System.Text.RegularExpressions.Regex(@"^[-]?\d+[.]?\d*$");
if(reg1.IsMatch(str))
{
//数字
}
else
{
//非数字
}
if(reg1.IsMatch(str))
{
//数字
}
else
{
//非数字
}
本文介绍了一种使用正则表达式判断字符串是否为数字的方法。通过实例代码展示了如何利用正则表达式来识别整数、小数以及负数。
1.判读是否为数字
转载于:https://www.cnblogs.com/smiler/archive/2010/07/15/1778094.html

被折叠的 条评论
为什么被折叠?