[ Last edited by xeibobin on 2010-10-30 at 17:58 ]作者: HAT 时间: 2010-10-28 13:45 给点真实数据吧作者: xeibobin 时间: 2010-10-28 13:55 有个文本如下,要获取“百度搜索”前面的12个字串:
11112223344百度搜索245566678899987122334566622222111233443442287百度搜索888777777765654332545668766543232456777788999title8787765444332333333343343445566677778888999999999999999999977654343
333344532234556677777777776百度搜索5443232223456787百度搜索888889776百度搜索543322233444454555666百度搜索6777887889997655555543432222344555555677643322323223344455555556566677777777
[ Last edited by xeibobin on 2010-10-28 at 14:10 ]作者: xeibobin 时间: 2010-10-28 13:56 麻烦HAT版主帮我看看,谢谢作者: clinttt 时间: 2010-10-28 16:02 这个超容易!作者: xeibobin 时间: 2010-10-28 16:46 怎样获取,不用sed吗,作者: xeibobin 时间: 2010-10-28 19:29 1.txt为要处理的文件,代码如下:
@echo off
type 1.txt |sed "s/百度搜索/\r\n/g" >>2.txt
Setlocal EnableDelayedExpansion
for /f "delims=" %%a in (2.txt) do (
set str=%%a&echo !str:~-12!>>3.txt
)
type 3.txt