public Boolean isnum(string value)
{
System.Text.RegularExpressions.Regex rex = new System.Text.RegularExpressions.Regex(@"^\d+$");
int result = -1;
if (rex.IsMatch(value))
{
result = int.Parse(value);
return true;
}
else
{
return false;
}
}
本文介绍了一个使用正则表达式检查输入字符串是否只包含数字的函数。通过匹配'^d+$'模式,该函数能准确判断并返回相应的布尔值。
8211

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



