普通防爆pression匹配的IP地址+通配符

问题描述:

我试图用一个Regularex pressionValidator匹配的IP地址(可能通配符)对IP过滤系统。

I'm trying to use a RegularexpressionValidator to match an IP address (with possible wildcards) for an IP filtering system.

我用正则表达式如下:

"([0-9]{1,3}\\.|\\*\\.){3}([0-9]{1,3}|\\*){1}"

在LINQPad与Regex.Matches运行时,它工作正常,但似乎并没有当我使用的验证工作。

Which works fine when running it in LINQPad with Regex.Matches, but doesn't seem to work when I'm using the validator.

有没有人有一个建议,作为到一个更好的正则表达式或为什么它会在测试工作,但不是在原地?

Does anyone have a suggestion as to either a better Regex or why it would work in test but not in situ?

干杯,埃德

ASP:RegularEx pressionValidator 不要求你仔细逃跑反斜杠。你应该尝试:

asp:RegularExpressionValidator does not require you to double-escape backslashes. You should try:

([0-9] {1,3} \\ |。\\ * \\){3}([0-9] {1,3} | \\ *){1}