Regex 正则表达式删除两个字符串之间的所有字符串?

Regex 正则表达式删除两个字符串之间的所有字符串?,regex,bash,text,notepad++,Regex,Bash,Text,Notepad++,我想删除目录中所有.txt文件的两个其他字符串之间的所有字符串。如何做到这一点 .txt文件的内容: Lorem ipsum dolor sit amet, consetetur sadipscing elitr [b]Download[/b] [b][url=https://www.example.com]File.mp4[/url][/b] [img]https://www.example.com/preview.jpg[/img] Size: 640 MB | Resolution:

我想删除目录中所有.txt文件的两个其他字符串之间的所有字符串。如何做到这一点

.txt文件的内容:

Lorem ipsum dolor sit amet, consetetur sadipscing elitr

[b]Download[/b]
[b][url=https://www.example.com]File.mp4[/url][/b]

[img]https://www.example.com/preview.jpg[/img]

Size: 640 MB | Resolution: 1280x720 | Runtime: 00:15:20 | Format: mp4

Tag1, Tag2, Tag3, Tag4, Tag5, Tag6, Tag7, Tag8

[b]Download[/b]
[b][url=https://www.example.com]File.mp4[/url][/b]
现在,我想删除以下各项之间的所有内容:

“格式:mp4”和[b]下载[/b]

因此,最终输出应该如下所示:

Lorem ipsum dolor sit amet, consetetur sadipscing elitr

[b]Download[/b]
[b][url=https://www.example.com]File.mp4[/url][/b]

[img]https://www.example.com/preview.jpg[/img]

Size: 640 MB | Resolution: 1280x720 | Runtime: 00:15:20 | Format: mp4

[b]Download[/b]
[b][url=https://www.example.com]File.mp4[/url][/b]
感谢您的友好帮助。

对于记事本++:

Ctrl+H

确保将正则表达式框标记为

我们使用的正则表达式执行以下操作:

(?<=Format: mp4)([^[]+)

(?<=Format: mp4)       - Starting after Format: mp4 (but not capturing)
([^[]+)                - Match all characters until [ 

(?您可以使用
sed

sed -i.bak '/Format: mp4$/,/^\[b\]Download/{/Format: mp4$/!{/^\[b\]Download/!d}}' *.txt

结果与您的要求完全一致,因此上面缺少一行免费代码下载[/b]

效果非常好!非常感谢兄弟。如果我们在
格式:mp4
[b]下载[/b]
之间有类似
[b]的内容,该怎么办