在 Notepad++ 和 Vim 中使用正则表达式进行批量替换 [英] Using regular expressions to do mass replace in Notepad++ and Vim

查看:39
本文介绍了在 Notepad++ 和 Vim 中使用正则表达式进行批量替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个大文本文件,如下所示:

So I've got a big text file which looks like the following:

<option value value='1' >A
<option value value='2' >B
<option value value='3' >C
<option value value='4' >D

它有几百行长,我真的不想手动完成.我试图使用的表达是:

It's several hundred lines long and I really don't want to do it manually. The expression that I'm trying to use is:

<option value='.{1,}' >

当我通过几个在线正则表达式测试器运行它时,它按预期工作.我基本上想删除 A、B、C 等之前的所有内容.问题是当我尝试在 Vim 和 Notepad++ 中使用该表达式时,它似乎找不到任何东西.

Which is working as intended when i run it through several online regular expression testers. I basically want to remove everything before A, B, C, etc. The issue is when I try to use that expression in Vim and Notepad++, it can't seem to find anything.

推荐答案

ABC等之前的所有内容

这看起来很简单,我一定是误解了你的意思.只是

That seems so simple I must be misinterpreting you. It's just

:%s/<.*>//

这篇关于在 Notepad++ 和 Vim 中使用正则表达式进行批量替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆