Onun yerine şunu deneyin. String replace olduğu için $1 çalışmayacak.

http://www.mysqludf.org/lib_mysqludf_preg/index.php