This is a single archived entry from Stefan Tilkov’s blog. For more up-to-date content, check out my author page at INNOQ, which has more information about me and also contains a list of published talks, podcasts, and articles. Or you can check out the full archive.

Regexp Quiz

Stefan Tilkov,

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