使用正则表达式从 html 中提取电子邮件 [英] Extract emails from html using regex

查看:44
本文介绍了使用正则表达式从 html 中提取电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 此页面中的正则表达式提取任何 jabber 帐户(电子邮件).

I'm trying to extract any jabber accounts (emails) using regex from this page.

我尝试过使用正则表达式:

I've tried using regex:

\w+@[\w.-]+|\{(?:\w+, *)+\w+\}@[\w.-]+

...但它没有产生预期的结果.

...but it's not producing the desired results.

推荐答案

这可能有效:

[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+

p = re.compile(ur'[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+', re.MULTILINE | re.IGNORECASE)
test_str = r'...'
re.findall(p, test_str)

参见示例.

这篇关于使用正则表达式从 html 中提取电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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