Regexp Quiz

, Feb 19, 2007

Quick, what’s this:

^[-!#$%∓'*+/0-9=?A-Z^_a-z{|}~](\.?[-!#$%∓'*+/0-9=?A-Z^_a-z{|}~])*@[a-zA-Z](-?[a-zA-Z0-9])*(\.[a-zA-Z](-?[a-zA-Z0-9])*)+$

Reply in the comments if you know what this regexp matches. Bonus point if you catch an omission.

On February 19, 2007 5:39 PM, Piers Cawley said:

It looks, at first glance, like a simple minded email address matcher. A fully compliant RFC822 format matcher runs to something like a page in length.

Even if it isn’t, I have the feeling you should be backwhacking your ‘.’s, and I doubt you really want & in your character ranges.

On February 21, 2007 4:09 AM, James Tauber said:

At first I thought email address too but the portion before the @ seems too permissive and the portion after the @ too restrictive. The portion after the @ might follow RFC1035, but it would exclude things like 37signals.com as domain names.

On February 21, 2007 7:49 AM, Stefan Tilkov said:

It is, in fact a simple-minded email regexp — I just found it funny that even at this length, it’s only a tiny portion of the real one:

http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html