#850: updating ucp_preg_replace function

All credit goes to Otomatic