c#匹配整数和小数的正则表达式
发布时间:2016-12-28 来源:查字典编辑
摘要:匹配整数的一种表达式:Regex.IsMatch(inputerstr,"^([0-9]{1,})$")其中Inputerstr是要匹配的字...
匹配整数的一种表达式:
Regex.IsMatch(inputerstr, "^([0-9]{1,})$")
其中Inputerstr是要匹配的字符串
这个表达式仅匹配整数,如果是整数形式返回true,否则为false
匹配小数格式的表达式:
Regex.IsMatch(inputerstr, "^([0-9]{1,}[.][0-9]*)$")
其中Inputerstr是要匹配的字符串
这个表达式仅匹配数字中有小数点格式的数字,如果是带有小数点格式的纯数字,返回true,否则为false。