If you care to go the way of DOMDocument():
$dom=new DOMDocument();
$dom->loadHTML($your_html);
$imgs = $dom->getElementsByTagName("img");
foreach($imgs as $img){
$alt = $img->getAttribute('alt');
if ($alt == 'pumpkin'){
$src = 'http://myhost.com/cache/img001.gif';
} else if ($alt== '*'){
$src = 'http://myhost.com/cache/img002.gif';
} else if ($alt== 'cool image'){
$src = 'http://myhost.com/cache/img003.jpg';
}
$img->setAttribute( 'src' , $src );
}