使用RegExp验证电子邮件... [英] Validate EMail with RegExp...
问题描述
我对正则表达式的理解很简陋,
充其量。
我有这个RegExp来进行非常简单的验证
电子邮件地址,但事实证明它拒绝
接受邮件地址大肆宣传。
任何人都可以帮助我调整它以便接受
地址,如 da ******* @ test- domain.net 呢?
这里有什么:
function validateEmail(eMail){
返回/ ^(\w + \。)*(\ w +)@(\ w + \。)+([a-zA-Z] {2,4})$ / .test(电子邮件);
}
TIA ...
-
Dag。
工作是饮酒课的诅咒
- Oscar Wilde
/ .test(eMail);
}
TIA ...
- -
Dag。
工作是喝酒的诅咒s
- Oscar Wilde
Dag Sunde写道:
我对正则表达式的理解是最基本的,
充其量。
我有这个RegExp来对一个
电子邮件地址进行非常简单的验证,但事实证明它拒绝接受邮件地址大肆宣传。
任何人都可以帮我调整它,以便接受
地址,如 da ******* @ test-domain.net 呢?
这里有什么:
功能validateEmail(电子邮件){
返回/^(\w+\。)*(\ w+)@(\\\\\。)+([ - zA- Z] {2,4})
/ .test(eMail);
}
TIA ...
> -
Dag。
工作是饮酒课的诅咒
- Oscar Wilde
嗨。谷歌上的一个快速搜索引发了一百万(也许是一个数十亿美元)电子邮件验证注册表的例子。
这是我找到的一个修补(在我测试时工作): -
var
r = / ^([a-zA-Z] [\\\ .-] * [A-ZA-Z0-9])@([A-ZA-Z0-9] [\w - ] * [A-ZA-Z0-9])\([A-ZA。 -Z] [A-ZA-Z\。] * [A-ZA-Z])
My understanding of regular expressions is rudimentary,
at best.
I have this RegExp to to a very simple validation of an
email-address, but it turns out that it refuses to
accept mail-addresses with hypens in them.
Can anybody please help me adjust it so it will accept
addresses like da*******@test-domain.net too?
Here''s what got:
function validateEmail(eMail) {
return /^(\w+\.)*(\w+)@(\w+\.)+([a-zA-Z]{2,4})$/.test(eMail);
}
TIA...
--
Dag.
Work is the curse of the drinking classes
-- Oscar Wilde
/.test(eMail);
}
TIA...
--
Dag.
Work is the curse of the drinking classes
-- Oscar Wilde
Dag Sunde wrote:
My understanding of regular expressions is rudimentary,
at best.
I have this RegExp to to a very simple validation of an
email-address, but it turns out that it refuses to
accept mail-addresses with hypens in them.
Can anybody please help me adjust it so it will accept
addresses like da*******@test-domain.net too?
Here''s what got:
function validateEmail(eMail) {
return /^(\w+\.)*(\w+)@(\w+\.)+([a-zA-Z]{2,4})
/.test(eMail);
}
TIA...
--
Dag.
Work is the curse of the drinking classes
-- Oscar Wilde
Hi. A quick search on google threw up a million (well perhaps a
billion) examples of e-mail validation reg-exps.
Here is one I found to tinker with (worked when I tested it):-
var
r=/^([a-zA-Z][\w\.-]*[a-zA-Z0-9])@([a-zA-Z0-9][\w-]*[a-zA-Z0-9])\.([a-zA-Z][a-zA-Z\.]*[a-zA-Z])
这篇关于使用RegExp验证电子邮件...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!