RegExp's – just like Marmite

Regular expressions are not everyone’s cup of tea. I recently started using a plugin for WordPress called Download Counter Advanced, and it works great for my Battrick stuff. I wanted an easy way to add in the date so that I could put “…downloads since…” and have the date automatically insert, all marked up correctly.

I hacked the plugin code, and managed this, and out of courtesy, sent the code to Andy Staines, the author of the plugin, via his contact form. This was his reply (emphasis mine):

Ah… um… thanks!

The shocking truth is that I don’t read regexp’s! I read that chapter three times and quickly concluded that I would prefer to gently flay myself with an old dressing gown while standing naked in the snow than try to follow the rules.

My son helps me out here who is known as a RegExp king. So can you confirm what your random sequence of numbers and letters below actually does in detail as it always looks to me like it was typed by a monkey swaying gently under the influence of Prozac…

It doesn’t help that I have had only about four hours sleep only to be rudely awoken by a barking dog. So I am not thinking clearly yet. So – you pass in the data row of the download? And get back the start date?

Andy

By Gary Jones

Husband, dad of twins, software engineering lead, and a middle-of-the-pack runner.