请教一下,这个批处理 删除 括号之间怎么做? (请把括号及括号内的内容删除) (…) . . .

This is what I am trying to do:
@echo This is some code that is
@echo Important to echo exactly as-is
@echo Even if I use parenthesis
@echo for something (like this)
So having that copied into clipboard. I have tried the following:
@echo This is some code that is
@echo Important to echo exactly as-is
@echo Even if I use parenthesis
@echo for something ^(like this^)
But this seems to affect my WANTED parentheses as well because I receive an error. To test this, I simply done:
@echo This is some code that is
@echo Important to echo exactly as-is
@echo Even if I use parenthesis
@echo for something ^(like this^)
Hey! This almost works, the text is copied all the way to the "s" in "this". It does not copy the last parentheses, or obviously the F's. Any ideas?
解决方案 It's obvious that you need three carets there :-)
@echo This is some code that is
@echo Important to echo exactly as-is
@echo Even if I use parenthesis
@echo for something (like this^^^)
Why? That is a bit tricky...
First the parser parses the block and escapes the part this^^^) to this^), the parenthesis was escaped here the first time.
But as you used a pipe, the complete block will be translated and transfered to a new cmd.exe instance.
C:\Windows\system32\cmd.exe
/S /D /c" ( @ echo This is some code is ... & @ echo for something (like this^) )"
And in the new instance it is necessary again to escape the closing parenthesis.
That's all!
And for more information you could read a similar question
本文地址: &
这就是我要做的: (@echo这是一些code是@echo重要呼应完全一样,是@echo即使我用括号@echo的东西(像这样))|剪辑 所以,具有复制到剪贴板。我曾尝试以下内容: (@echo这是一些code是@echo重要呼应完全一样,是@echo即使我用括号@echo的东西^(好像是这个^))|剪辑 但这似乎影响到我的WANTED括号以及因为我收到一个错误。为了测试这一点,我只是做了: (@echo这是一些code是@echo重要呼应完全一样,是@echo即使我用括号@echo的东西^(好像是这个^)FFF)|剪辑 嘿!这几乎工程,将文本复制一路的“S”的“本”。它不会复制最后一个括号,或者明明是F公司。任何想法?解决方案 很明显,你需要三个插入符号有: - ) (@echo这是一些code是@echo重要呼应完全一样,是@echo即使我用括号@echo的东西(像这样^^^))|剪辑 为什么呢?这是一个有点棘手... 首先解析器解析块和脱一部分此^^^)到这^)中,括号在这里躲过了第一次。 但是当你使用一个管道,完整的块将被翻译并转移到一个新的CMD.EXE实例。结果 C:\\ WINDOWS \\ SYSTEM32 \\ CMD.EXE / S / D / C“(@回声这是一些code为...&放大器; @回声的东西(好像是这个^))”
和在新的情况下,有必要再次逃脱右括号。结果这就是全部!和获取更多信息,你可以读到类似的问题结果SO:为什么推迟扩张失败的管道块内时,code
本文地址: &
扫一扫关注官方微信

我要回帖

更多关于 批处理 if 括号 的文章

 

随机推荐