开发者

Regex for validation e-mail addresses [duplicate]

开发者 https://www.devze.com 2023-03-10 21:30 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: What is the best regular expression for validating email addresses?
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

What is the best regular expression for validating email addresses?

I am using the following regular expression to validate e-mail addresses:

^[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]$

It doesn't consider the following e-mail address valid: username@q.c开发者_开发知识库om, but according to our customer it is a valid e-mail.

How do I modify the following regular expression statement to accept username@q.com as a valid e-mail address?


Why do you need a regular expression to check the validity of an e-mailadres? If I would fill in fake@fake.com the regular expression would also say it is valid.

In my opinion, regular expressions take a lot of runtime to evaluate, and mostly do not make you accomplish your goal. Think about why you actually need it, and perhaps go for a simpler one that just checks if it is of the form #@#.# (#=some text) See: http://www.linuxjournal.com/article/9585

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号