Regex for validating emails

Often, email validation code for web applications checks only for the position of @ and period characters, also assuming the @ character will be in the front of period. Did you know you can use a Java Script Regular Expressions method to check email addresses?

Keep it simple, and don't mark some e-mail addresses that are actually valid as invalid.

"Some people, when confronted with a problem, think ' I know, I'll use regular expressions.' Now they have two problems."——Jamie Zawinski on regular expressions; paraphrasing the Unix Haters Handbook on As @Simon pointed out, your regular expression might consider some valid addresses as invalid.

You can use them to constrain input, apply formatting rules, and check lengths. This How To shows how you can use regular expressions within ASP. Objectives Overview Using a Regular Expression Validator Control Using the Regex Class Common Regular Expressions Additional Resources If you make unfounded assumptions about the type, length, format, or range of input, your application is unlikely to be robust.

To validate input captured with server controls, you can use the Regular Expression Validator control. Input validation can become a security issue if an attacker discovers that you have made unfounded assumptions.

I hear and understand a lot of the comments on this thread mention that regex saves the user from a typo and such.