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