[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  1. @ECHO OFF
  2. FOR /L %%A IN (0 1 8)DO SET _%%A=1
  3. (FOR /F "DELIMS=" %%F IN (123.TXT)DO (
  4.  FOR %%M IN (%%F)DO CALL :CN "%%M"
  5. ))>B.TXT
  6. GOTO :EOF
  7. :CN NUM
  8. SET FLAG=&SET N=
  9. SET "NUM=%~1"
  10. SET "STR=%NUM%FEDCBA9876543210"
  11. SET/aLEN=0x%STR:~15,1%
  12. IF %LEN%==13 (
  13.  FOR /L %%C IN (0 1 12)DO CALL :ISNUM "%%NUM:~%%C,1%%"
  14. )
  15. IF NOT DEFINED FLAG (
  16.  IF "%N%"=="52" ECHO=%NUM% %N%
  17.  IF "%N%"=="39" ECHO=%NUM% %N%
  18. )
  19. GOTO :EOF
  20. :ISNUM NUM
  21. IF DEFINED _%~1 (SET/aN+=%~1)ELSE SET FLAG=1
复制代码
1

评分人数

    • mxarky: 测试过程中有时报错技术 + 1
如无特别说明,代码测试环境均为 XP SP3

TOP

  1. @echo off
  2. (for /f "delims=" %%a in (1.txt) do (
  3.   for %%b in (%%a) do (
  4.     set "str=%%b"
  5.     setlocal enabledelayedexpansion
  6.     if not "!str:~12,1!"=="" if "!str:~13!"=="" set a=$!str!
  7.     if defined a for /l %%c in (0 1 8) do set a=!a:%%c=!
  8.     if "!a!"=="$" (
  9.       for /l %%c in (0 1 12) do set/a sum+=!str:~%%c,1!
  10.       for %%c in (52 39) do if "%%c"=="!sum!" echo,!str! !sum!
  11.     )
  12.     endlocal   
  13.   )
  14. ))>Result.txt
复制代码
1

评分人数

    • cutebe: 好紧凑的思路技术 + 1

TOP

  1. @echo off&setlocal enabledelayedexpansion
  2. set _52=i&set _39=i
  3. for /f "delims=" %%i in (123.txt) do (
  4.     for %%j in (%%i) do (
  5.         set str=%%j#
  6.         if "!str:~13!"=="#" for /l %%k in (0 1 8) do set str=!str:%%k=!
  7.         if !str! == # (
  8.            set sum=&set str=%%j&for /l %%k in (0 1 12) do set/a "sum+=!str:~%%k,1!"
  9.            if defined _!sum! echo,%%j !sum!
  10.         )
  11.     )
  12. )
  13. pause
复制代码
1

评分人数

TOP

兄弟们写得太复杂,我来个简单的
  1. @echo off
  2. setlocal enableDelayedExpansion
  3. for /f "tokens=*" %%i in ('findstr "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-
  4. 9][0-9][0-9]" 123.txt') do (
  5. for %%j in (%%i) do (
  6. set str=%%j&set count1=
  7. if not "!str:~12!"=="" set /a count1+=1
  8. if !str:~12! GEQ 0 set /a count1+=1
  9. if !str:~12! LEQ 9 set /a count1+=1
  10. if !count1!==3 echo %%j>>new.txt
  11. )
  12. )
复制代码

TOP

再来个vbs版的
  1. option explicit
  2. dim class1, class2, class3, class4, str1, str2
  3. set class1 = createobject("scripting.filesystemobject")
  4. set class2 = class1.opentextfile("123.txt")
  5. set class4 = class1.createtextfile("new.txt", 2)
  6. do until class2.atendofstream
  7. str1 = class2.readall
  8. for each str2 in func1(str1)
  9. class4.writeline str2
  10. next
  11. loop
  12. function func1(str)
  13. set class3 = new regexp
  14. class3.pattern = "\d{13}"
  15. class3.global = true
  16. set func1 = class3.execute(str)
  17. end function
复制代码

TOP

返回列表