I haven't posted a "WTF" Regular Expression before today because RegEx's are a fairly complex animal. Well, that and I haven't gotten a submission for one. They're incredibly useful tools for parsing and validation, but I think most (including myself) are glad that there are places like RegExLib.com around to save us from the intricacies of lazy quantifiers, backtracking, and lookbehinds.

There are definitely a few out there who will brave the trenches and roll their own expression. After looking at Matt Brown's colleague's 347-character-long, partially-working "mm/dd/yyyy" date validator (used, no less in a language with built in support for date validation), it's pretty clear that not everyone belongs on the front line ...

# ED: Line breaks added

For you regex junkies, Matt explains more ...

I'm not sure if my favorite part is the use of non-capturing groupings ("(?: )") without any actual backreferences, with the mixing of capturing groups ("( )"), or if my favorite part is that the year section of the regular expression is:


...which ends up allowing any four digits EXCEPT 0000. But 0001 is valid.

And if you haven't voted for a the logo already, please take a moment to vote. No login or anything required. There's a good amount of votes in already, so I will probably close the "polls" soon.