Board logo

标题: [文件操作] 批处理BAT怎样删除txt文件中指定字符串之前的字符? [打印本页]

作者: amio555    时间: 2014-4-10 08:40     标题: 批处理BAT怎样删除txt文件中指定字符串之前的字符?

这个是删除之后的
  1. @echo off&setlocal enabledelayedexpansion
  2. (for /f "tokens=*" %%a in (log.txt) do (
  3. set .=%%a&set .=!.: 字符串=☆!
  4. for /f "delims=☆" %%b in ('echo !.!')do echo %%b
  5. ))>log2.txt
  6. pause
复制代码
需要 这个的反向版本。。。
作者: apang    时间: 2014-4-10 18:50

http://www.bathome.net/viewthread.php?tid=29029
这个帖子的问题解决了没有?
作者: amio555    时间: 2014-4-10 20:21

回复 2# apang


    解决了啊,用的2楼中代码

这个问题通过搜索本论坛 也解决了
vbs的


Set fso = CreateObject("Scripting.FileSystemObject")
text = fso.OpenTextFile("log2.txt",1).ReadAll
With New RegExp
   .Pattern = "(.*?xxx)(.*)"
   .IgnoreCase = True
   .Global = True
   text = .Replace(text,"$2")
End With
fso.OpenTextFile("log2.txt",2,True).Write text
作者: CrLf    时间: 2014-4-10 21:11

  1. @echo off&setlocal enabledelayedexpansion
  2. (for /f "tokens=*" %%a in (log.txt) do (
  3. set .=%%a&echo;!.:* 字符串=!
  4. ))>log2.txt
  5. pause
复制代码

作者: zhangxinjian    时间: 2014-5-10 17:32

俺是菜鸟,也不知道怎么解决的




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