Board logo

标题: [文本处理] 批处理保留特定字符串内的字符 [打印本页]

作者: koofking    时间: 2014-5-16 19:39     标题: 批处理保留特定字符串内的字符

a.txt文档里有多条相同代码

<div class="pure-u-1-6 headwall-cell" userid="216270">
<a href="javascript:void(0)" class="userHeadButton" userid="216270">

有多条 里面还包含其他代码 不相同的

如何提取userid="这里面的代码" 每条都有两个相同的ID 只保留一个

然后前面加上网址 http://baidu.com/浏览器批量打开
作者: 522235677    时间: 2014-5-17 00:48

  1. @echo off & setlocal enabledelayedexpansion
  2. for /f "delims=" %%a in ('findstr "userid" 1.txt') do (
  3. set str=%%a
  4. set str=!str:^<=!
  5. set str=!str:^>=!
  6. for %%b in (!str!) do (
  7. if "!y!"=="1" (
  8. for /f %%c in (%%b) do if defined %%~c (cd.) else (set "%%~c=1" & echo start "" http://...%%~c)
  9. set y=
  10. )
  11. if "%%b"=="userid" set y=1
  12. )
  13. )
  14. pause
复制代码

作者: koofking    时间: 2014-5-17 22:04

回复 2# 522235677


无法批量打开  能修改一下 批量输出到另一个TXT文件吗  每行一个网址
作者: 522235677    时间: 2014-5-17 23:38

回复 3# koofking


    echo 去掉了吗




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2