更精确的电子邮件地址 [英] a more precise re for email addys

查看:127
本文介绍了更精确的电子邮件地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以写一个_only_匹配电子邮件地址?我已经在网上搜索了几个例子,并在网上找到了几个例子,但是所有这些例子都产生了太多的误报......这里有一些例子来自

谷歌我已经尝试过:


re.compile(''([\\\\\ - ] + @ [\ w \。\ - ] +)'')

re.compile(r''[\\\\ - ] [\\\\ - \。] + @ [ \ w \ - ] [\\\\] + [a-zA-Z] {1,4}'')

re.compile(''('\\ \\ S +)@(\ S +)'')


所有这些都会找到电子邮件地址,但他们也会找到其他东西。

有人可以证明如何为电子邮件撰写更准确的邮件?


顺便说一句,这不是针对垃圾邮件,而是像任何工具都可能以糟糕的方式使用。


谢谢!

Is it possible to write an re that _only_ matches email addresses? I''ve
been googling around and have found several examples on the Web, but all
of them produce too many false positives... here are examples from
Google that I''ve experimented with:

re.compile(''([\w\.\-]+@[\w\.\-]+)'')
re.compile(r''[\w\-][\w\-\.]+@[\w\-][\w\-\.]+[a-zA-Z]{1,4}'')
re.compile(''(\S+)@(\S+)'')

All of these will find email addys, but they also find other things.
Could someone demonstrate how to write a more accurate re for emails?

BTW, this is not for spam, but like any tool could be used in a bad way.

Thanks!

推荐答案

我相信Perl模块中有一个精确的版本。
http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html

你能刷一下吗?


Jim

There is a precise one in a Perl module, I believe.
http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html
Can you swipe that?

Jim


OMG,太丑了:D $

Jim写道:
OMG, that is so ugly :D

Jim wrote:
我相信Perl模块中有一个精确的。
http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html
你能刷一下吗?

Jim
There is a precise one in a Perl module, I believe.
http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html
Can you swipe that?

Jim








rbt> re.compile(''([\\\\\ - ] + @ [\\\\ - ] +)'')

rbt> re.compile(R ''[\w\ - ] [\w\-\。] + @ [\w\ - ] [。\w\-\] + [一-zA-Z] {1,4}'')

rbt> re.compile(''(\ S +)@(\ S +)'')


rbt>所有这些都会找到电子邮件地址,但他们也会找到其他的

rbt>事情。


我认为决定你的正则表达式是否符合你想要的唯一方法

是提供一组必须接受的字符串和另一组必须

拒绝。供应这两套,我相信这里的任何人都可以

拿出一套区分两套的普通快递。


Skip

rbt> re.compile(''([\w\.\-]+@[\w\.\-]+)'')
rbt> re.compile(r''[\w\-][\w\-\.]+@[\w\-][\w\-\.]+[a-zA-Z]{1,4}'')
rbt> re.compile(''(\S+)@(\S+)'')

rbt> All of these will find email addys, but they also find other
rbt> things.

I think the only way to decide if your regular expression does what you want
is to provide a set of strings it must accept and another set which it must
reject. Supply those two sets and I''m sure any number of people here can
come up with a regular express that distinguishes the two sets.

Skip


这篇关于更精确的电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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