Regular expression for email

Posted by Nadeem on Stack Overflow See other posts from Stack Overflow or by Nadeem
Published on 2010-05-25T12:46:09Z Indexed on 2010/05/25 12:51 UTC
Read the original article Hit count: 357

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about regex