Use preg_replace_callback instead of preg_replace

Use preg_replace_callback instead of just suppressing the preg_replace \e modifier deprecation warning