需要帮助才能找到电子邮件验证的正则表达式。 [英] Need help to find regex for Email validation.

查看:101
本文介绍了需要帮助才能找到电子邮件验证的正则表达式。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下内容验证电子邮件:



 var reg = / ^ \w +([ -  +。'] \w +)* @@ \w +([ - ] \w +)* \.\w +([ - ] \w +)* $ /; 





但我不想要以数字开头的电子邮件。

我该怎么办?添加上面的正则表达式。

请帮助。

解决方案

/;





但我不想要以数字开头的电子邮件。

我该怎么办?添加上面的正则表达式。

请帮忙。


如果你想从第一个字母中排除数字,那么把它放在你的正则表达式模式的前面,

 ^ [^ \d] 



第一个^表示字符串的开头,第二个^表示方括号表示排除,\d表示匹配数字。

了解详情: http: //www.w3schools.com/jsref/jsref_obj_regexp.asp [ ^ ]


将\D添加到正则表达式字符串的前面:\ d是一个数字,\d只是一个数字。



但更有可能的是,您想要添加[A-Za-z],将其限制为大写或小写字符。

I am trying to validate an email using following:

var reg = /^\w+([-+.']\w+)*@@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;



but i dont want the email that starts with a digit.
what should i add in the above regex.
please help.

解决方案

/;



but i dont want the email that starts with a digit.
what should i add in the above regex.
please help.


If you want to exclude digit from the first letter, then put this at the front of your regex pattern,

^[^\d]


The first ^ means the start of the string, the second ^ in the square brackets means to exclude, \d means matching a digit.
Learn more: http://www.w3schools.com/jsref/jsref_obj_regexp.asp[^]


Add \D to the front of the regex string: "\d" is a digit, \d is anything but a digit.

But more likely, you want to add [A-Za-z] instead, to restrict it to just an upper or lower case character.


这篇关于需要帮助才能找到电子邮件验证的正则表达式。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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