Deep Voodoo

Just come across this on photomatt.net – a function to convert double line breaks to paragraphs, with various other niceties thrown in for good measure. Two thoughts on this: firstly, that is a very handy and shiny function. Secondly, it rather rams home just how crazy and unintelligible regular expressions can end up being, even to the experienced. Hell, even the documentation is confusing. Just take a look at it – sit there, stare, and marvel at its sheer impregnability. I was going to quote a short passage in this post, but it appears the sheer number of back and forward slashes has overwhelmed WordPress.

In fact, the only thing I’ve come across more voodoo-like than regexes is mod_rewrite. Which uses regexes.

Now, if you will excuse me, all this thinking is making my brain overheat…

11 Responses to “Deep Voodoo”

  1. […] Categories: Tech Blog, 492 words   Friendly URLs Since I’m not adverse to regular expressions, I’ve tidied up the addre […]

    •  Gravatar for Nina
    • From Nina
    • Tuesday 28 September 2004 at 22:16

    Nothing to do with the post, if I’m being quite honest, I don’t understand. ANYWAY… I still don’t have a link in the blogroll. I’m gonna get offended very soon.

    •  Gravatar for Fatty
    • From Fatty
    • Wednesday 29 September 2004 at 09:55

    Afraid it doesn’t look like I can currently add you without recoding the whole thing – my blogroll gets its updates from http://www.blo.gs, and it seems LiveJournal accounts only support this if you pay for the account. So ‘fraid there’s not much I can do about it…

  2. Despite the tons of examples and docs, mod_rewrite is voodoo. Damned cool voodoo, but still voodoo.
    •  Gravatar for random
    • From random
    • Friday 10 December 2004 at 15:15

    I dunno — writing regular expressions is usually easy, unless you need lots of conditionals and lookahead/lookbehind. That’s how it seems to me, anyway: it’s voodoo when I have to read them, but when I write one it’s the simplest thing in the world…

  3. Mod-rewrite is like a work of art. You never know how it’s going to turn out until you try it.

    •  Gravatar for Elaine
    • From Elaine
    • Friday 10 December 2004 at 16:58

    I love Dorothea Salo’s Brief Guide to Regular Expressions — a wonderfully clear intro to the topic. I find myself referring to it quite a bit; thankfully, I don’t have to dip into regexps very often!

  4. Thanks for that link, Elaine! That might help me out some time.

  5. Don’t you love it when documentation includes the word “might”?

  6. shudder After having spent the last 2 hours intensively reworking my mod_rewrite rules in WPMU this gives me the shivers, and I didn’t use any complex regex, just the thought of it..

    •  Gravatar for Aankhen
    • From Aankhen
    • Saturday 11 December 2004 at 16:47

    It’s true that regexes can be quite scary to comprehend, but it does make things easier if you use the equivalent of Perl’s x flag (eXtended legibility), which allows neat stuff like as much whitespace as you want, and comments, too. If I recall correctly, Python has re.VERBOSE to help with that.

    On further investigation, it appears to simply be /x for PHP too.