:- @echo off&setlocal enabledelayedexpansion
- set /p var=<a.txt
- set q=%var:~0,1%
- set h=%var:~-1%
- for /f "delims=:" %%a in ('findstr /n "." a.txt') do set /a z=%%a
- :loop
- for /f "delims=:" %%a in ('findstr /n "^%q%" a.txt') do set /a x=%%a
- if %x% equ %z% (
- set /a m+=1
- set "q=!q!!var:~1,1!"
- set "var=!var:~1!"
- goto loop
- )
- :loop2
- for /f "delims=:" %%a in ('findstr /n "%h%$" a.txt') do set /a x=%%a
- if %x% equ %z% (
- set /a j+=1&set var=!var:~0,-1!
- set h=!var:~-1,1!!h!
- goto loop2
- )
- for /f "delims=" %%a in (a.txt) do (
- set "str=%%a"
- echo !str:~%m%,-%j%!
- )
- pause
复制代码
|