Позвольте мне попробовать:
//search for links with href
$links = preg_match_all('/href="(?P<link>[^"]*?)"/i',$text1, $matches);
if(count($matches['link'])>0){
// explode non links pieces of code
$blocks = preg_split('/href="(?P<link>[^"]*?)"/i',$text1);
// for assurance
// non-links pieces should be equal a links plus one
if(count($matches['link']) == (count($blocks)-1))
{
// to lower non-link pieces
$blocks = array_map("strtolower", $blocks);
$size = count($matches['link']);
for($i=0;$i<$size;$i++){
//putting together the link again without change a case
$blocks[$i] .= 'href="'.$matches['link'][$i].'"';
}
$text1 = join("",$blocks);
}
} else {
$text1 = strtolower($text1);
}
Удачи:)