批处理提取指定字符串后面的字符
我只要sa后面的字符61.143.130.214satasklist211.142.127.238saqwerty123456124.207.134.70sa1qaz2w...
我只要sa后面的字符
61.143.130.214 sa tasklist
211.142.127.238 sa qwerty123456
124.207.134.70 sa 1qaz2wsx
60.219.138.179 sa ""
60.210.103.92 sa 123
60.222.163.168 sa ok 展开
61.143.130.214 sa tasklist
211.142.127.238 sa qwerty123456
124.207.134.70 sa 1qaz2wsx
60.219.138.179 sa ""
60.210.103.92 sa 123
60.222.163.168 sa ok 展开
2个回答
展开全部
@echo off
for /f "tokens=2* delims= " %%i in (1.txt) do echo %%j
pause
文本是1.txt
for /f "tokens=2* delims= " %%i in (1.txt) do echo %%j
pause
文本是1.txt
追问
我试了不行啊·我是想把每行sa后面的字符提取出来然后保存到另一个文档里,也就是说sa前面的字符都删了(包括sa),然后再一行一行的保存到另一文档了··61.143.130.214 sa tasklist
211.142.127.238 sa qwerty123456
124.207.134.70 sa 1qaz2wsx
60.219.138.179 sa ""
60.210.103.92 sa 123
60.222.163.168 sa ok
追答
@echo off
(for /f "tokens=2* delims= " %%i in (1.txt) do echo %%j)>2.txt
pause
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
'以下代码保存为VBS类型文件
'______________________________________________
'Dim objct
dim Fso,CD,Spl,Read,File,STx,S0R
set fso=createobject("scripting.filesystemobject")
set cd=createobject("useraccounts.commondialog")
'______________________________________________
'Main code
file=showopen("All FILE|*.*|TXT|*.TXT",chr(46))
if len(file)=0 then wscript.quit
filename=mid(file,instrrev(file, chr(92))+1)
do
spl=inputbox("请输入作为分隔符的字符串")
if spl=false then
wscript.quit
else
if len(spl)>0 then exit do
end if
loop
do
stx=inputbox("请输入要截取的内容"&CHR(13)&"[1]*"&spl&CHR(13)&"[2]"&spl&"*")
if stx=false then
wscript.quit
else
if len(stx)>0 then exit do
end if
loop
read=fso.opentextfile(file).readall
for each i in split(read,vbcrlf)
if stx=1 then
s0r=s0r&trim(mid(i,1,instrrev(i,spl)-len(sa)))&chr(13)
else
s0r=s0r&trim(mid(i,instrrev(i, spl)+len(sa)))&chr(13)
end if
next
if right(s0r,1)=chr(13) then s0r=left(s0r,len(s0r)-1)
fso.createtextfile("change_"&filename).write s0r
'______________________________________________
'Function code
public function showopen(byval typeval,byval dirval)
cd.initialdir=dirval
cd.filter=typeval
cd.showopen
showopen=cd.filename
if showopen=vbnullstring then exit function
end function
'______________________________________________
'Dim objct
dim Fso,CD,Spl,Read,File,STx,S0R
set fso=createobject("scripting.filesystemobject")
set cd=createobject("useraccounts.commondialog")
'______________________________________________
'Main code
file=showopen("All FILE|*.*|TXT|*.TXT",chr(46))
if len(file)=0 then wscript.quit
filename=mid(file,instrrev(file, chr(92))+1)
do
spl=inputbox("请输入作为分隔符的字符串")
if spl=false then
wscript.quit
else
if len(spl)>0 then exit do
end if
loop
do
stx=inputbox("请输入要截取的内容"&CHR(13)&"[1]*"&spl&CHR(13)&"[2]"&spl&"*")
if stx=false then
wscript.quit
else
if len(stx)>0 then exit do
end if
loop
read=fso.opentextfile(file).readall
for each i in split(read,vbcrlf)
if stx=1 then
s0r=s0r&trim(mid(i,1,instrrev(i,spl)-len(sa)))&chr(13)
else
s0r=s0r&trim(mid(i,instrrev(i, spl)+len(sa)))&chr(13)
end if
next
if right(s0r,1)=chr(13) then s0r=left(s0r,len(s0r)-1)
fso.createtextfile("change_"&filename).write s0r
'______________________________________________
'Function code
public function showopen(byval typeval,byval dirval)
cd.initialdir=dirval
cd.filter=typeval
cd.showopen
showopen=cd.filename
if showopen=vbnullstring then exit function
end function
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询