普通防爆pression匹配的IP地址+通配符 [英] Regular Expression to match IP address + wildcard

查看:162
本文介绍了普通防爆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}

这篇关于普通防爆pression匹配的IP地址+通配符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆