Auto-Linking URLs with PHP

A week or so ago I was working on a bug in the auto-linking code for Laconica, the software that powers Squashing that particular bug wasn’t too hard, but I wanted to take the functionality a step further (closer to the calibre of Gmail) and it turns out, writing robust auto-linking code is more difficult than it initially seems. So I played with it a little at a time here and there, testing as many edge cases as I could think of. The result is a function that’s more robust than most URL auto-linking code I’ve come across. I […]

Negative Word Matching with Regular Expressions

Today on the #codeigniter IRC channel someone asked about how to match a string that didn’t start with a specific word using a regex. I quickly threw out that, off the top of my head, /^(word){0}/ should work. Well, surprisingly, it didn’t. Turns out negatively matching words with regular expressions is a little more difficult. After a little research I came up with a working solution: /^(?!word).*/ This post by Jeff Atwood helped: Excluding matches with Regular Expressions