Regular expression for email

Possible Duplicate:
What is the best regular expression for validating email addresses?

I tried the reg expression

^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+.([a-zA-Z])+([a-zA-Z])+

for the email validation.

Since I want the user to allow submitting even with the empty email address. So I changed the reg ex to

(^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+.([a-zA-Z])+([a-zA-Z])+)?

But this expression accepts any email address without any validation.


Thanks Konerak!!!! I changed the expression to

^(([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+.([a-zA-Z])+([a-zA-Z])+)?$

and this is working for me.


Welcome. http://www.ex-parrot.com/pdw/Mail-RFC822-Address.html


如何验证字符串是否处于有效的电子邮件格式

链接地址: http://www.djcxy.com/p/16576.html

上一篇: 使用RegEx c#从文本中提取电子邮件地址

下一篇: 电子邮件正则表达式