简体   繁体   中英

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

I have 1000~ txt files that contain data inside curly {} brackets. 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? 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. Note that the BA in the example is completely random. Only B is constant. 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)
Find what: (.*\r\n)(B = {.*}\r\n)(.*)
Replace with: $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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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