Updated Regular Expression for E-Mail Posted on August 5th, 2005 by

We discovered a small bug in our old regular expression for checking valid e-mail addresses. When a user tried to use an address with capital letters on a form, it failed to match the regular expression. We updated the regular expression to account for capital letters anywhere in the e-mail address.

^[_a-zA-Z0-9-]+(.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(.[a-zA-Z0-9-]+)*.(([a-zA-Z]{2,3})|([Aa][Ee][Rr][Oo]|[Aa][Rr][Pp][Aa]|[Cc][Oo][Oo][Pp]|[Ii][Nn][Ff][Oo]|[Mm][Uu][Ss][Ee][Uu][Mm]|[Nn][Aa][Mm][Ee]))$

This new expression will recognize user@domain.com and uSeR@DOmaIN.CoM and (hopefully) any other capitalization a user places on an e-mail address.

Currently, only the e-mail forms on the eCards have been updated, but we’ll try to update every place we check for a valid e-mail address as soon as possible.

 


2 Comments

  1. Joe Lencioni says:

    In ColdFusion, you should also be able to use reFindNoCase with the previous regular expression… That would simplify things a bit. I believe that most implementations of regular expressions have a case-insensitive mode as well, so you could just note that here and simplify the expression.

  2. I am often fighting with the various services I use online with this one. You see, people often forget about other characters that can be used in email addresses. See this site as an example: http://www.remote.org/jochen/mail/info/chars.html
    Personally, all of my email accounts allow me to do things such as userid+sitename@email.host.com