删除除 '<' 之间的字符之外的所有内容& '>,'在 Vim 中 -- 从 Gmail“收件人”中提取电子邮件地址场地

发布于 2024-12-05 00:26:17 字数 1575 浏览 1 评论 0 原文

我有一个以逗号分隔的电子邮件地址列表,每个实际地址前面都带有联系人姓名(来自 Gmail)。下面是一个示例:

Fred Flintstone <[email protected]>, Wilma Flintstone <[email protected]>, Barney Rubble <[email protected]>, Bamm-Bamm Rubble <[email protected]>,

转换为:

[email protected], [email protected], [email protected], [email protected],

背景信息:我正在尝试将联系人列表粘贴到 webex 邀请中,该邀请仅接受电子邮件地址。

删除 Vim 中除正则表达式匹配之外的所有内容 相关,但所有电子邮件在这种情况下,地址在一行上。

I have a comma-delimited list of email addresses with each actual address prepended by the contact's name (from Gmail). Here's an example:

Fred Flintstone <[email protected]>, Wilma Flintstone <[email protected]>, Barney Rubble <[email protected]>, Bamm-Bamm Rubble <[email protected]>,

converts to:

[email protected], [email protected], [email protected], [email protected],

Background info: I am trying to paste the list of contacts into a webex invite, which can only accept email addresses.

Remove everything except regex match in Vim is related, but all the email addresses are on one line in this case.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

预谋 2024-12-12 00:26:17

你尝试过吗?

:s/.\{-}\%(\(,\s*\)\|<\(.\{-}\)>\)/\1\2/g

以下也将起作用:

:s/.*/\=join(map(split(submatch(0), ','), "matchstr(v:val, '<\\zs.*\\ze>')"), ', ')

Have you tried?

:s/.\{-}\%(\(,\s*\)\|<\(.\{-}\)>\)/\1\2/g

The following will also work:

:s/.*/\=join(map(split(submatch(0), ','), "matchstr(v:val, '<\\zs.*\\ze>')"), ', ')
笑叹一世浮沉 2024-12-12 00:26:17

使用 awk

    echo "Fred Flintstone <[email protected]>, Wilma Flintstone <[email protected]>, Barney Rubble <[email protected]>, Bamm-Bamm Rubble <[email protected]>
"|awk -F'<|>' '{for (i=1;i<=NF;i++)printf (i%2==0)?$i",":""}'

或在 VIM 中

:%s/,/\r/g
:%s/.*<\(.*\)>/\1/g

with awk

    echo "Fred Flintstone <[email protected]>, Wilma Flintstone <[email protected]>, Barney Rubble <[email protected]>, Bamm-Bamm Rubble <[email protected]>
"|awk -F'<|>' '{for (i=1;i<=NF;i++)printf (i%2==0)?$i",":""}'

or in VIM

:%s/,/\r/g
:%s/.*<\(.*\)>/\1/g
2024-12-12 00:26:17

你能不能把它放到Excel中,
然后用逗号分割数据,然后
然后进行查找和替换以消除尖括号

除非您使用一些代码来执行此操作,否则这将是最简单的
除非你有十万个地址

Could you not put it into Excel,
then split the data on the comma and then
and then do a find and replace to get rid of the angel bracket

Unless you are using some code to do it this would be the easiest
unless you have 100,000's of thousand addresses

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文