changed str_replace to preg_replace