Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 如何将vim中的匹配规则合并为一个?_Regex_Vim - Fatal编程技术网

Regex 如何将vim中的匹配规则合并为一个?

Regex 如何将vim中的匹配规则合并为一个?,regex,vim,Regex,Vim,我有一个日志文件,其中有调试、正常和关键条目,以及一些不以常规(对于此类日志)数据开头的信息,例如[20130313:123412] [210313:100114] NORMAL: this is normal log [210313:100114] DEBUG: ../../common/ Additional info: number of .... 我想删除DEBUG条目以及那些不以[开头的条目 我知道我可以做到这一点: :g/DEBUG/d 及 如何将其合并为一个?或正确使用正则表

我有一个日志文件,其中有调试、正常和关键条目,以及一些不以常规(对于此类日志)数据开头的信息,例如
[20130313:123412]

[210313:100114] NORMAL: this is normal log
[210313:100114] DEBUG: ../../common/
Additional info: 
number of ....
我想删除
DEBUG
条目以及那些不以
[
开头的条目

我知道我可以做到这一点:

:g/DEBUG/d


如何将其合并为一个?或正确使用正则表达式?

将它们转换为正规则或负规则(视情况而定),然后您可以使用
\\\124;
(“Or”)来匹配其中一个

:g/^[^\[]\|DEBUG/d

那就可以了。
^[^\[]
对于以
[
以外的行开头的行,或者包含
调试的行,效果非常好!谢谢:)我正在等待计时器(我相信10分钟后:)
:g/^[^\[]\|DEBUG/d