我不验证电子邮件。我想要做的是在(html)字符串中找到(然后更改)3种不同类型的“电子邮件”内容:
- 普通电子邮件:例如 [电子邮件受保护]
- mailto href:例如
[电子邮件受保护]">[电子邮件受保护]
- 别名 href:例如
[email protected]">用户的电子邮件
然后我将转换每个示例到一个自定义的 html 字符串中,然后由 JS 修改(通过 Spamspan 进行反垃圾邮件收集):
<span class="spamspan">
<span class="u">user</span>
@
<span class="d">example.com</span>
(<span class="t">Spam Hater</span>)
</span>
所以你可以看到我还必须找到这些类型的输入,将电子邮件解析为用户、域和(可选)显示值。我目前正在努力使用正则表达式来查找这些电子邮件...在 PHP 中解析它们应该很简单。
编辑:目前,我被锁定在 PHP4 中。将查看 http://php-html.sourceforge.net/ 来解析 HTML。
I'm not validating emails. What I want to do is find (and then change) 3 separate types of "email" content in a (html) string:
- a plain email: eg [email protected]
- a mailto href: eg
<a href="mailto:[email protected]">[email protected]</a>
- an aliased href: eg
<a href="mailto:[email protected]">user's email</a>
I'm then going to transform each example into a custom html string that will then be modified by JS (anti-spam harvesting via Spamspan):
<span class="spamspan">
<span class="u">user</span>
@
<span class="d">example.com</span>
(<span class="t">Spam Hater</span>)
</span>
So you can see I also have to find these types of input, parse the email into user, domain and (optionally) a display value. I'm struggling at the moment with regexes to find these emails... parsing them should be straightfoward in PHP.
Edit: At the moment, I'm locked into PHP4. Will take a look at http://php-html.sourceforge.net/ for parsing HTML.
发布评论
评论(1)
您需要一个 HTML 解析器 和一个 电子邮件正则表达式。
You need a HTML parser and an email regex.