三方SED- @echo off
- sed -r "s/[^0-9]*([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*/\1/" 1.txt
- pause
复制代码 P的话不一定很精准- @echo off&setlocal enabledelayedexpansion
- for /f "tokens=1-4 delims=." %%a in (1.txt) do (
- set ipa=&set "ipd="
- set a=%%a&set d=%%d
- for /L %%i in (1,1,3) do (
- if "!a:~-%%i,1!" leq "9" if "!a:~-%%i,1!" geq "0" set ipa=!a:~-%%i,1!!ipa!
- )
- for /L %%i in (0,1,2) do (
- if "!d:~%%i,1!" leq "9" if "!d:~%%i,1!" geq "0" set ipd=!ipd!!d:~%%i,1!
- )
- echo !ipa!.%%b.%%c.!ipd!
- )
- pause
复制代码
|