注定goto多次,注定慢... ...- @echo off & setlocal enabledelayedexpansion
- :: 逐个字符找【11位,以1[34578]开头】的数字
-
- for /f "delims=" %%i in ('type 1.txt') do (
- call :split "%%i"
- )
-
- pause & exit /b
-
- :: ------------------------------------------
-
- :split [line]
- if not defined line set line=%~1
- set n=!line:~,1!
- if not defined n goto :eof
- if !n! leq 9 (
- if !n! geq 0 (
- set _num=1
- )
- )
- if defined _num (
- set "_num="
- set num=!num!!n!
- ) else set "num="
- if "!num!" neq "" if "!num:~10!" neq "" (
- set _legal=
- if "!num:~,1!"=="1" (
- for %%i in (3,4,5,7,8) do (
- if not defined _legal (
- if "!num:~1,1!"=="%%i" set _legal=1
- )
- )
- )
- if defined _legal (
- echo;!num!& set "num="
- ) else set num=!num:~1!
- )
- set line=!line:~1!
- if "!line!" neq "" goto :split
- goto :eof
复制代码
|