$newcode = preg_replace("/(IMG SRC=\"?)(\/[^\"\/]+)/", "\\1" . $domain . "\\2", $code);
$newcode = preg_replace("/(HREF=\"?)(\/[^\"\/]+)/", "\\1" . $domain . "\\2", $code);