批处理提取括号内的内容保存到新的txt中

批处理提取括号内的内容保存到新的txt中
txt内容如下:【下面是个例子,我随便找的】
Starting {a brand new|a fresh|a whole new|a different} book {is really a|can be a|is often a|is usually a} risk, {much like|the same as|exactly like|similar to} falling in love. You have to {invest in|agree to|spend on|plan to} it.
我想做的就是将 { } 括号内的内容提取出来保存到新的txt中.每一个括号内的放在一行
保存到新的txt应该是
a brand new|a fresh|a whole new|a different
is really a|can be a|is often a|is usually a
much like|the same as|exactly like|similar to
类似这种类型.多谢了
bulls2008 1年前 已收到1个回答 举报

lhy519 幼苗

共回答了20个问题采纳率:90% 举报

@echo off
::下两行据实修改
cd/d "d:test"
set "fn=a.txt"
(for /f "delims=" %%j in ('findstr "{.*}" "%fn%"')do (
set "L=%%j"
setlocal enabledelayedexpansion
set "L=!L:{=y{!"
call :yky
endlocal
))>"new.txt"
pause&goto :eof
:yky
if "%L%"==""echo;>con&goto :eof
for /f "tokens=2,4,6,8,10* delims={}" %%a in ("!L!")do (
for %%i in ("%%a" "%%b" "%%c" "%%d" "%%e")do (
if not "%%~i"=="" (
set/p={%%~j}...>con
echo;%%~i)set "q=%%~f"
))
set L=!q!&goto :yky

1年前

2
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 16 q. 1.774 s. - webmaster@yulucn.com