In your case I would have done something like this...
/* add [domain_name] string where the domain need to be added */
<p>here is a load of text. blah blah blah. My link is <a href="[domain_name]/mydocuments/images">is here</a>. Blah blah.
The using [man]str_replace[/man] witch should be pretty fast I would have added the domain ...
If you cant make that change you can try something like this ...
define('_New_Domain','http://mydomain.com');
$my_str = "<p>here is a load of text. blah blah blah. My link is <a href=\"/mydocuments/images\">is here</a>. Blah blah.";
$search = "/\< *[a][^\>]*[href] *= *[\"\']{0,1}([^\"\'\ >]*)/i";
$replace = "<a href=\""._New_Domain."$1";
echo preg_replace($search, $replace, $my_str);