Vim 正则表达式反向引用 [英] Vim regex backreference
本文介绍了Vim 正则表达式反向引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想这样做:
%s/shop_(*)/shop_\1 wp_\1/
为什么 shop_(*)
不匹配任何东西?
Why doesn't shop_(*)
match anything?
推荐答案
如果我理解正确,你想要 %s/shop_\(.*\)/shop_\1 wp_\1/
If I understand correctly, you want %s/shop_\(.*\)/shop_\1 wp_\1/
转义捕获括号并使用 .*
匹配任意数量的任意字符.
Escape the capturing parenthesis and use .*
to match any number of any character.
(您的搜索正在搜索shop_",后跟任意数量的左括号,后跟右括号)
(Your search is searching for "shop_" followed by any number of opening parentheses followed by a closing parenthesis)
这篇关于Vim 正则表达式反向引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文