Regular expressions can be very useful and efficient if used properly. For a while now in some of our applications we have been using the following regular expression to check e-mail addresses for proper formatting.
^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*.(([a-z]{2,3})|(aero|coop|info|museum|name))$
This will ensure that the user has entered a properly formatted e-mail address such as user@domain.com
.
Leave a Reply