0
点赞
收藏
分享

微信扫一扫

C#正则表达式

眸晓 2022-03-11 阅读 71

匹配整数的一种表达式:

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 条评论