post-page

Validate email regular expression bug in WordPress and other CMSs

4
responses
by
 
on
January 19th, 2004
in
Code

a ‘+’ symbol is a valid part of an email username, and can be used in debugging and SPAM control. I use username+websitepostedon@server.com (the real address being username@server.com) when I post my email on a site where it could get displayed for spam harvesters.

However, most CMSs use this regular expression in their email address checking algorithms.

"/^([a-z0-9_]|\-|\.)+@(([a-z0-9_]|\-)+\.)+[a-z]{2,4}\$/i"

Please replace that line with this so the plus sign gets recognized. That is a much better practice. Thank you!

"/^([a-z0-9_+]|\-|\.)+@(([a-z0-9_]|\-)+\.)+[a-z]{2,4}\$/i"

Another option from Phil :

I’ve always used these two in conjunction. The first one we don’t want, and the second one we do want.
(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)
^.+\@(\[?)[-a-zA-Z0-9\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$

heading
4
Responses

 

Comments

  1. ikkr (1 comments.) says:

    rtr

  2. Phillip Harrington (1 comments.) says:

    I’ve always used these two in conjunction. The first one we don’t want, and the second one we do want.

    (@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)

    ^.+\@(\[?)[-a-zA-Z0-9\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$

    Picked this up somewhere, and it seems to accept the + sign.

  3. Scott says:

    used it and it wouldnt accept any emails even valid ones.

  4. Mark (14 comments.) says:

    which expression are you talking about?



Obviously Powered by WordPress. © 2003-2013

page counter
css.php