Do not use preg function here, it's way too slow.

Using `preg_match` here can be very very slow and sometimes even crash the page. Anyway, we don't need a regular expression for this simple task. 
For some reason I left that as a big `<?php ?>` block rather than do it line-by-line like everywhere else. I'm still a little conflicted about it.