我想搜索并替换这样的内容:
document.addEventListener('keyup', function (e) {
if (evtesc.keyCode === 27) {
document.getElementById("search-largeinput").value = "";
}
};
到
"foo : foo"
但当然,我需要一个正则表达式。
我尝试使用下面的S& R命令,但似乎在搜索到的字符串中使用backref不起作用:
"foo"
知道我该怎么做?
感谢。
答案 0 :(得分:2)
%s/\([a-z]\+\)\zs : \1\ze//
[a-z]
表示“任何字符”,\+
表示“重复1次以上”。
\ 1完美无缺!