Replaced ereg with preg_match due to php 5.3 deprecation