【发布时间】:2012-04-27 18:16:29
【问题描述】:
我正在寻找一个正则表达式来从文本文件中删除电子邮件地址。
输入文件:
Hannah Churchman <xxxx@xxxxxxxx.com>; Julie Drew <xxxx@xxxxxxxxx.com>;
输出文件:
Hannah Churchman; Julie Drew;
我认为像 s///g 这样的通用正则表达式会是一个很好的起点,但我无法找到适合使用 Vim 的表达式?
类似
:%s/ <\(.*?\)>//g
不起作用。错误是“E486:找不到模式:”。
:%s#[^ <]*>##g almost works but it leaves the space and < behind.
:%s# <##g to remove the " <" remaining stuff.
关于如何更好地制作此命令的任何提示?
【问题讨论】:
-
.*?在 vim 中不是非贪婪匹配,参见 stackoverflow.com/a/1305957/155299