- @echo off&setlocal enabledelayedexpansion
- Set iCurOffset=0
- Set iCurLen=-1
- Set strOutString=
- for /f "tokens=1,2,3" %%i in (a.txt) do (
- if %%j GEQ !iCurOffset! (
- Set /a iLineLen=%%i+%%j
- if !iLineLen! GTR !iCurLen! (
- Call :MergeStr !iLineLen! %%k
- )
- Set /a iCurOffset=%%j
- )
- )
- echo %strOutString%
- pause
- goto :EOF
-
- :MergeStr
- Set /a iMore=%1-%iCurLen%
- Set strNewWord=%2
- if %iCurLen%==-1 (Set strOutString=%2) else (
- Set strOutString=!strOutString:~0,%iCurLen%!!strNewWord:~-%iMore%!
- )
- Set /a iCurLen=%1
复制代码
[ 本帖最后由 slore 于 2010-8-27 23:47 编辑 ] |