复制代码
- @echo off
- set "pp=[1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]*$"
- set flag=&set /p ip= 请输入IP地址 &cls
- echo %ip%|findstr /x "%pp%">nul||set flag=a
- set var=%ip:.= %
- for %%a in (%var%) do if %%a gtr 255 set flag=a
- if defined flag (echo %ip% 错误) else echo %ip% 正确
- pause
Environment variable substitution has been enhanced as follows: %PATH:str1=str2% would expand the PATH environment variable, substituting each occurrence of "str1" in the expanded result with "str2". "str2" can be the empty string to effectively delete all occurrences of "str1" from the expanded output. "str1" can begin with an asterisk, in which case it will match everything from the beginning of the expanded output to the first occurrence of the remaining portion of str1. |
欢迎光临 批处理之家 (http://bbs.bathome.net/) | Powered by Discuz! 7.2 |