vim中的条件正则表达式? [英] Conditional regex in vim?
本文介绍了vim中的条件正则表达式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以进行条件正则表达式(例如 http://www.regular中描述的正则表达式-expressions.info/conditional.html )在Vim中?
Is it possible to do conditional regex (like the one described in http://www.regular-expressions.info/conditional.html) in Vim?
推荐答案
Vim正则表达式没有此功能,因此您将需要使用一些重复来创建相同的行为:
Vim regex does not have this feature, so you will need to use a bit of repetition to create the same behaviour:
/\(\%(condition\)\@=then\|\%(condition\)\@!else\)
请注意,您必须在Vim版本中使用两次该条件,并且,在那时/其他部分中,先行/后向必须始终相反,否则您的正则表达式将不正确。
Note that you have to use the condition twice in the Vim version and the lookahead/lookbehind must always be the opposite in the then/else parts otherwise your regex will not be correct.
这篇关于vim中的条件正则表达式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文