Wow, has it really been a month since I’ve posted? I’ve been essentially working four jobs for the past two weeks and barely have time to breath. It’s an awesome time to be a PHP programmer in the NYC area - there is no shortage of work at the moment.

Enough excuses, on to the topic. Last week I posted a question on the CakePHP Google Groups asking how to build case insensitive routes. I knew you could use regular expressions, but I’ve always done case insensitivity by adding “/i” at the end. This doesn’t work here since Cake is adding the start and end markers to the regular expression.

No one responded to my question, so I spent a few hours digging through regular expression syntax, figuring there had to be a way to apply case insensitivity to a part of an expression rather than the whole thing. I finally found it.

If you want to have an “about” page that is linked to by “/about”, “/About”, or “/aBoUt” you can use:
Router::connect(’/(?i:about)’, array(’controller’ => ‘pages’, ‘action’ =>’display’, ‘about’));

The “?i:” applies case insensitive matching to the grouping which is marked by the parens surrounding it.

Popularity: 39% [?]