.net - 为什么RegularExpressionValidator中的 "\d+{1,4}(?:[.,]\d{1,4})?"抛出异常: "Nested quantifier {"

标签 .net asp.net regex validation

我有

<asp:RegularExpressionValidator ValidationExpression="\d+{1,4}(?:[.,]\d{1,4})?" />

但它不起作用,解析器抛出 ArgumentException:

parsing "\d+{1,4}(?:[.,]\d{1,4})?"

Nested quantifier {.

我的错误在哪里?我想允许像 xxxx,xxxx 这样的字符串 - 不需要 1 到 4 位数字和十进制数字,例如:100099,99 , 0,2498

最佳答案

这看起来不对:

\d+{1,4}

应该是这样的:

\d{1,4}

+ 表示“一个或多个”,{1,4} 表示一到四之间。它们不能一起使用,因为它没有意义。

关于.net - 为什么RegularExpressionValidator中的 "\d+{1,4}(?:[.,]\d{1,4})?"抛出异常: "Nested quantifier {",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2739216/

相关文章:

c# - asp.net 文本在禁用时不发送值

regex - 我怎样才能插入到 Yahoo!管道提要标题?

java - 正则表达式模式和匹配器问题

regex - Notepad++ 替换仅包含空格和/或制表符的行

c# - 大字节[]的优化

c# - ASP.NET DropDownValue 不会跨 webfarm 中的一台服务器持久保存

.net - HttpMethod 中缺少 Web API 路由约束补丁

c# - 写 SEO 友好的 url 得到无限循环 asp.net

C# MailMessage to stream - 编码问题

c# - 获取 Silverlight ClientBin 目录的路径