Email Validation RegExp

I had to search my desktop files and email history for forty minutes before I turned this up:

var rfc2822 =
/^[\w!#$%&'*+/=?^`{|}~-]+(?:\.[\w!#$%&'*+/=?^`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])*)+\.(?:[a-z]{2,4}|museum|travel)$/i;


That’s a JavaScript variable declaration, but the RegExp is valid for Perl and can be quickly translated for other languages.

1 Comment

  1. pyrolupus said,

    November 13, 2007 at 16:18

    For anyone following along, I missed a plus sign in there. Fixed, now.

    Pyro