How to match IP address by using 'findstr'? Or any other method of batch in windows

前端 未结 5 1453
广开言路
广开言路 2021-01-21 07:30

    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 \"finds

5条回答
  •  粉色の甜心
    2021-01-21 08:28

    A simplistic regex string would be

    (1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.(1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.(1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.(1?[0-9]?[0-9]|2[0-4][0-9])|25[0-5]

    to match exactly the range of allowable IP addresses.

    EDIT: Based on comments below and Regular expressions in findstr information, modify the above regex to [0-2][0-9][0-9]\.[0-2][0-9][0-9]\.[0-2][0-9][0-9]\.[0-2][0-9][0-9] to match IP addresses. Apparently FINDSTR really is that limited in regular expression interpretation.

提交回复
热议问题