replace some preg_replace by preg_replace_callback (refs #4125)