如何通过使用'FINDSTR“相匹配的IP地址?或批处理窗口中的任何其他方法 [英] How to match IP address by using 'findstr'? Or any other method of batch in windows

查看:971
本文介绍了如何通过使用'FINDSTR“相匹配的IP地址?或批处理窗口中的任何其他方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    正如标题所说,我想的IP地址与一批窗口匹配,请告诉我,我该怎么办呢?


    我看到 FINDSTR 可以匹配包含 [0-9] 正则表达式,但它怎么能FINDSTR匹配出现一至三次吗?

    As the title said, I want to match ip address with batch in windows, please tell me how I can do it?
    I see that "findstr" can match with regex like "[0-9]", but how can "findstr" matches it appears one to three times?

推荐答案

由于 FINDSTR 的正则表达式的支持是有点...过时,你通常无法使用大多数正则表达式,你在网络上找到。下面的数字四分相匹配,用点分隔:

Since findstr's regex support is a bit ... dated, you usually can't use most regexes you find on the web. The following matches four runs of digits, separated by dots:

ipconfig | findstr /r "[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*"

不过,如果你只是对地址而不是子网掩码兴趣,你可能想使用

However, if you're only interested in addresses and not the subnet masks, you might want to use

ipconfig | findstr /r "Address.*[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*"

是的,如果也将匹配之类的东西地址:232345.534.78678.345 这显然不是一个IP地址。但通常 IPCONFIG 不吐这样的字符串。

And yes, if would also match things like Address: 232345.534.78678.345 which is obviously not an IP address. But usually ipconfig doesn't spit out such strings.

这篇关于如何通过使用'FINDSTR“相匹配的IP地址?或批处理窗口中的任何其他方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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