本帖最后由 happy886rr 于 2016-3-20 23:24 编辑
回复 1# enoone1
gk开关- @echo off&setlocal enabledelayedexpansion
- set /p str=请输关键词: &echo,
- for /f "tokens=1* delims=:" %%A in ('type test.txt^|findstr /n /i /c:"!str!"') do (
- set gk=1
- for /f "tokens=1* delims=:" %%a in ('type test.txt^|findstr /n "{"') do (
- if !gk! equ 1 (
- if %%a gtr %%A (
- set gk=0
- ) else (
- set /a mark=%%a-1
- )
- )
- )
- if not defined #!mark! (
- set "#!mark!=1" &set gk=0
- for /f "tokens=1* delims=:" %%a in ('type test.txt^|findstr /n .*') do (
- if %%a equ !mark! (set gk=1)
- if !gk! equ 1 (echo,%%b &set "dis=%%b"
- if "!dis: =!"=="}" (
- set gk=0
- )
- )
- )
- )
- )
- pause>nul
复制代码 标记算法- ...
- for /f "tokens=1* delims=:" %%a in ('type test.txt^|findstr /n /i /c:"!str!"') do (set #%%a=1)
- for /f "tokens=1* delims=:" %%a in ('type test.txt^|findstr /n .*') do (
- if "%%b"=="{" (set /a N=%%a-1)
- if defined #%%a (set "#%%a=" &set "#!N!=1")
- for /f "tokens=1* delims=:" %%a in ('type test.txt^|findstr /n .*') do (
- if defined #%%a (set gk=1)
- ...
复制代码
|