views:

64

answers:

4

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.

+1  A: 

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

The MYYN
I think this is unrealistic because RFC822 includes a lot of legacy address types that are rarely needed or supported by current software.
kervin
yeah, this is not practical. far better is this, and the discussion around it: http://www.regular-expressions.info/email.html
Richard
A: 
Steven Mackenzie
A: 

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.

Nadeem
And what about the + character?
Sean Kinsey