我之前发布了一个关于这个的问题,但是忘记了另外一个案例。这是我的第一个问题:
Regex to include and exclude certain IPs
另一种情况是路由表中的这一行:
D*EX 0.0.0.0/0 [170/19664] via 10.10.10.1, 5d22h, Vlan10
[170/19664] via 10.10.10.1, 5d22h, Vlan20
如何编辑正则表达式以从下面的正则表达式中排除0.0.0.0/0 IP:
(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})\/(?:[\d]{1,3})\b(?! is variably)
我试过这些,但没有成功:
(?! 0.0.0.0/0)(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})\/(?:[\d]{1,3})\b(?! is variably)
AND
(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})\/(?:[\d]{1,3})\b(?! is variably)(?! 0.0.0.0/0)
谢谢
达蒙
正如@Greg Hewgill所评论的,我认为您可以使用
if
语句。你知道吗如果你真的想用正则表达式来解决它,这就是它。https://regex101.com/r/jTu8cj/2
(?!0\.0\.0\.0/0)(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})\/(?:[\d]{1,3})\b(?! is variably)
相关问题 更多 >
编程相关推荐