电子邮件地址正则表达 [英] Email address regular expression

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

问题描述

我一直在使用此模式来验证电子邮件地址:


^([0-9a-z] +)([0-9a-z \.- _] +)@([0-9a-z \。-_] +)\。([0-9a-z] +)


但我已经最近发现用破折号的地址不会通过这个测试。


我觉得他们应该通过。


出了什么问题?


-

Floydian Slip(tm) - 从月球的黑暗面广播 ;

Random Precision Productions(tm)

67 Union St.#2D,Winooski,Vt.05404-1948 USA

星期日,7-晚上8点 - 冠军101.3 FM,科尔切斯特; 102.1 FM,Randolph,Vt。
cc*@floydianslip.com - 目的:RandomPrec - www.floydianslip.com

I''ve been using this pattern to verify email addresses:

^([0-9a-z]+)([0-9a-z\.-_]+)@([0-9a-z\.-_]+)\.([0-9a-z]+)

But I''ve recently discovered that addresses with a dash in them won''t
pass this test.

Seems to me they should pass.

What''s wrong?

--
Floydian Slip(tm) - "Broadcasting from the dark side of the moon"
Random Precision Productions(tm)
67 Union St. #2D, Winooski, Vt. 05404-1948 USA
Sundays, 7-8 pm - Champ 101.3 FM, Colchester; 102.1 FM, Randolph, Vt.
cc*@floydianslip.com - AIM: RandomPrec - www.floydianslip.com

推荐答案

Craig Bailey写道:
Craig Bailey wrote:
我一直在使用这种模式验证电子邮件地址:

^([0-9a-z] +)([0-9a -z\。-_] +)@([0-9a-z \。-_] +)\。([0-9a-z] +)

但是我最近发现,带有破折号的地址不会通过这个测试。

在我看来他们应该通过。
I''ve been using this pattern to verify email addresses:

^([0-9a-z]+)([0-9a-z\.-_]+)@([0-9a-z\.-_]+)\.([0-9a-z]+)

But I''ve recently discovered that addresses with a dash in them won''t
pass this test.

Seems to me they should pass.




[AZ] =从A到Z的所有字符,也许是\-可能有帮助吗?


-

垃圾邮件:新闻组(at )cr ********* @ verisign-sux-klj.com

电子邮件:< 0110001100101110011000100111010101110010011 010110

11001010100000001100011011100100110000101111010011 011100

1100001011100100010111001100011011011110110 1101001 00000>



[A-Z] = All characters from A to Z, maybe a \- might help ?

--
Spam:newsgroup(at)cr*********@verisign-sux-klj.com
EMail:<0110001100101110011000100111010101110010011 010110
11001010100000001100011011100100110000101111010011 011100
11000010111001000101110011000110110111101101101001 00000>


在文章< Qp ********************* @ news-server.bigpond .net.au>,

" 127.0.0.1" <新闻组(在)CR ********* @ verisign-sux-ijlkl.com>写道:
In article <Qp*********************@news-server.bigpond.net.au>,
"127.0.0.1" <newsgroup(at)cr*********@verisign-sux-ijlkl.com> wrote:
Craig Bailey写道:
Craig Bailey wrote:
我一直在使用这种模式验证电子邮件地址:
^([0-9a-z] +)([0-9a-z \。-_] +)@([0-9a-z \。-_] +)\。([0- 9a-z] +)

但我最近发现,带有破折号的地址不会通过这个测试。

似乎我应该通过。
I''ve been using this pattern to verify email addresses:

^([0-9a-z]+)([0-9a-z\.-_]+)@([0-9a-z\.-_]+)\.([0-9a-z]+)

But I''ve recently discovered that addresses with a dash in them won''t
pass this test.

Seems to me they should pass.



[AZ] =从A到Z的所有字符,也许是\-可能有帮助吗?



[A-Z] = All characters from A to Z, maybe a \- might help ?




Aaaahhhh。但破折号不需要逃脱,做到了吗?你是否建议在表达式的第一部分添加短划线?
喜欢这个?


^([0-9a-z - ] +)([0-9a-z \。-_] +)@([0-9a-z \。-_] +)\。([0-9a-z] +)


当然,这会让某人用短划线开始他们的地址,

我不确定是否允许在真实的电子邮件地址中使用。


-

Floydian Slip(tm) - "从月球的阴暗面广播

Random Precision Productions(tm)

67 Union St.#2D,Winooski,Vt.05404-1948 USA

星期日,晚上7-8点 - 冠军101.3 FM,科尔切斯特; 102.1 FM,Randolph,Vt。
cc*@floydianslip.com - 目的:RandomPrec - www.floydianslip.com



Aaaahhhh. But a dash doesn''t need to be escaped, do it? Are you
suggesting a add a dash to the first part of the expression? Like this?

^([0-9a-z-]+)([0-9a-z\.-_]+)@([0-9a-z\.-_]+)\.([0-9a-z]+)

Of course, that would allow someone to start their address with a dash,
which I''m not certain is allowable in real email addresses.

--
Floydian Slip(tm) - "Broadcasting from the dark side of the moon"
Random Precision Productions(tm)
67 Union St. #2D, Winooski, Vt. 05404-1948 USA
Sundays, 7-8 pm - Champ 101.3 FM, Colchester; 102.1 FM, Randolph, Vt.
cc*@floydianslip.com - AIM: RandomPrec - www.floydianslip.com


[未发布到alt组]


Craig Bailey写道:
[ not posted to alt groups ]

Craig Bailey wrote:
我一直在使用这种模式验证电子邮件地址:

^([0-9a- Z] +)([0-9A-z\。-_] +)@([0-9A-z\。-_] +)\。([0-9A-Z] +)<无线电通信/>
但我最近发现,带有破折号的地址不会通过这个测试。

对我来说,他们应该通过。

出了什么问题?
I''ve been using this pattern to verify email addresses:

^([0-9a-z]+)([0-9a-z\.-_]+)@([0-9a-z\.-_]+)\.([0-9a-z]+)

But I''ve recently discovered that addresses with a dash in them won''t
pass this test.

Seems to me they should pass.

What''s wrong?




不[0-9a-z \。-_]表示:0到9和a to z和dot to underscore?


试试[0-9a-z \ ._-]

HTH


-

我有垃圾邮件过滤器工作。

给我发邮件包括urkxvq (有或没有引号)
主题行中的
,或者你的邮件将被无情地丢弃。



Doesn''t [0-9a-z\.-_] mean: 0 to 9 and a to z and dot to underscore?

try [0-9a-z\._-]
HTH

--
I have a spam filter working.
To mail me include "urkxvq" (with or without the quotes)
in the subject line, or your mail will be ruthlessly discarded.


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

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