public bool Isnum(string str)
{
const string pattern = "^[0-9]*$";
Regex rx = new Regex(pattern);
return rx.IsMatch(str); //bool类型
}
分享个正则表达式判断字符串是否为数字
最新推荐文章于 2024-05-06 16:00:39 发布
public bool Isnum(string str)
{
const string pattern = "^[0-9]*$";
Regex rx = new Regex(pattern);
return rx.IsMatch(str); //bool类型
}