Updated to use preg_replace instead of ereg_replace as the latter is deprecated