Skip to content
CONTACT

Law of the two problems

PROGRAMMING AND BUGS

Some people, when confronted with a problem, think: 'I know, I'll use regular expressions.' Now they have two problems.

— Jamie Zawinski, Usenet post from 1997, traced by Jeffrey Friedl on the regex.info blog (2006)
VIDEO.EXE16:9

Regular expressions are formulas for searching text: extremely powerful and written in a language that looks like a cat walked across the keyboard. They are used, for example, to check whether an email address is valid. The result is a line of symbols that no human being can read after ten minutes, including the person who wrote it.

The first problem was finding the emails. The second is working out why the formula accepts 'bob@@.co.uk' and rejects the accountant. The third, because there's always one more, is that the only colleague who understood it has changed jobs.

I use them with the caution you'd show a spell found in the attic. They work, but every time I change one I seem to hear thunder in the distance. And usually, in fact, the server goes down.