联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: SearchString.bat - 从文本首列中找出所有的由特定字母组成的单词所在行 :: by: 无奈何 - 2005-9-26 - 联系:wunaihe@gmail.com :: 用法:SearchString test.txt :: 说明: - 测试环境WinXP。将“test.txt”替换为实际处理文本,可将 :: “set str=abcde”中abcde 替换为其它欲测字母。 :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @echo off del log.txt 2>nul setlocal ENABLEDELAYEDEXPANSION :: 获取首列单词并提交string函数处理 for /f "tokens=1" %%i in (%1) do ( call :string %%i>>log.txt ) :: 从原文件中确定匹配单词所在行 for /f "delims=" %%i in (log.txt) do ( findstr /n /r "\<%%i\>" %1 ) endlocal goto :EOF :: 判断单词只有特定字母组成后输出 @echo off :string setlocal ENABLEDELAYEDEXPANSION set m=0 set n=0 set str=abcde set str2=%1 :loop if not defined str2 echo %1&endlocal &goto :EOF if not defined m endlocal &goto :EOF call set m=%%str:~%n%,1%% set str2=!!str2:%m%=!! set /a n+=1 goto loop goto :EOF
abc 中国DOS联盟 ABC 中国DOS联盟 asdfdsa 中国DOS联盟 ghkll 中国DOS联盟 ABdba 中国DOS联盟 qwwq 中国DOS联盟 ABCDE 中国DOS联盟 woniu 中国DOS联盟 hgdfh 中国DOS联盟 ABBCCBBAA 中国DOS联盟 wunaihe 中国DOS联盟 fghg 中国DOS联盟 qwerewq 中国DOS联盟 aaaaaaaaaa 中国DOS联盟 aa 中国DOS联盟 a 中国DOS联盟
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: loopback.bat - 从文本首列中查找回环单词(正反拼读相同)所在行 :: by: 无奈何 - 2005-9-26 - 联系:wunaihe@gmail.com :: 用法:loopback test.txt :: 说明: - 测试环境WinXP。将“test.txt”替换为实际处理文本。 :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @echo off del log.txt 2>nul setlocal ENABLEDELAYEDEXPANSION :: 获取首列单词并提交string函数处理 for /f "tokens=1" %%i in (%1) do ( call :string %%i>>log.txt ) :: 从原文件中确定匹配单词所在行 for /f "delims=" %%i in (log.txt) do ( findstr /n /r "\<%%i\>" %1 ) endlocal goto :EOF :: 判断单词为回环字符后输出 :string @echo off setlocal ENABLEDELAYEDEXPANSION set m=0 set n=0 set str=%1 set str2= :loop if not defined m ( if /i "%str%" == "%str2%" ( echo %str%&endlocal &goto :EOF ) else endlocal &goto :EOF ) call set m=%%str:~%n%,1%% set /a n+=1 set str2=!m!!str2! goto loop goto :EOF