Correcting $mathes typo.
Using triple equals for preg_match evaluation.
Replacing simple preg_match with a less expensive substr check.
Replacing simple preg_match with less expensive strpos.
Replacing simple preg_match with inexpensive substr and strlen.
Replacing simple preg_split with less expensive explode.