@echo off Setlocal Enabledelayedexpansion set n=0 for /f "delims=" %%i in (a.txt) do ( set "ke=%%i" set ke1=!ke: =! set m=0 call :1 ) echo %wang% pause goto :eof :1 if not "!ke1:~%m%,1!"=="" set /a m+=1goto 1 if %m% gtr %n% set n=%m%set wang=%ke% goto :eof
batman:
复制代码 代码如下:
@echo off set num=0 for /f "delims=" %%i in (a.txt) do set "str=%%i"call,set "str=%%str: =%%"call :lp "%%i" call,echo %%_%num%%% %num%个字符 pause>nulgoto :eof :lp set "str=%str:~1%"set /a n+=1 if defined str goto lp if %n% geq %num% set "num=%n%"set "_%num%=%~1" set "n=0"