C#正则表达式

眸晓

关注

阅读 71

2022-03-11

匹配整数的一种表达式:

Regex.IsMatch(inputerstr, "^([0-9]{1,})$") //网上的

Regex.IsMatch(inputerstr, @"^(\d+)$") //自己的

匹配小数格式的表达式:

Regex.IsMatch(inputerstr, "^([0-9]{1,}[.][0-9]*)$")

Regex.IsMatch(inputerstr, @"^\d+[.]\d*)$")

匹配负数格式的表达式:

Regex regex = new Regex(@"^[-]\d+[.]\d*$");

精彩评论(0)

0 0 举报