简体   繁体   English

如何批量删除txt文件中的括号及其内容?

[英]How to mass delete brackets and their contents in txt files?

I have 1000~ txt files that contain data inside curly {} brackets.我有 1000~ txt 文件,其中包含大括号内的数据。 example:例子:

A = {
 bananas = 5
 apples = 1
}
B = {
 oranges = 5
 bananas = 3
   BA = {
      apples = 19
   }
 cookies = 2
}
C = {
 bananas = 19
}

Now how exactly would i delete all lines from B = { to the } that closes the brackets?现在我将如何删除从 B = { 到 } 的所有行来关闭括号? The biggest problem i have is the fact that the B brackets can sometimes contain more brackets... Feel free to suggest any program, only requirements being that its free and simple enough to use for a moron like me.我遇到的最大问题是 B 括号有时可以包含更多括号...请随意推荐任何程序,唯一的要求是它足够免费和简单,可以供像我这样的白痴使用。 Note that the BA in the example is completely random.请注意,示例中的 BA 是完全随机的。 Only B is constant.只有 B 是常数。 what i would want:我想要什么:

A = {
 bananas = 5
 apples = 1
}
C = {
 bananas = 19
}

Ive tried notepad++.我试过记事本++。

Open only the documents you want to modify仅打开要修改的文档
CTRL+H (replace) CTRL+H(替换)
Find what: (.*\r\n)(B = {.*}\r\n)(.*)查找内容: (.*\r\n)(B = {.*}\r\n)(.*)
Replace with: $1$3替换为: $1$3
check.查看。 matches new line匹配新行
Click Replace All in All Opened Documents单击所有打开的文档中的全部替换
Verify results before saving保存前验证结果

helpful information: https://superuser.com/questions/481276/how-to-make-regex-match-across-multiple-lines-in-notepad有用的信息: https://superuser.com/questions/481276/how-to-make-regex-match-across-multiple-lines-in-notepad

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM