I have never been good with regular expressions...

PHP Code:
function getTitle($Url){
    
$str file_get_contents($Url);
    if(
strlen($str)>0){
          
$str preg_replace('/\s+/'' '$str);
        
preg_match("/\<title\>(.+)\<\/title\>/i",$str,$title);
        if (isset(
$title[1])) {
            if (
$title[1]=='' ){
                return 
$Url;
            }else{
                
                return 
trim($title[1]);
            }
        }else{
            return 
$Url;
        }
            
    }


works fine for any normal <title< </title> tags
also works for titles with new lines...

Im trying to get it to work with titles that have and id or something else

so how do i tweak this:
preg_match("/\<title\>(.+)\<\/title\>/i",$str,$title);
to get this:
<title id="pageTitle">THIS TITLE</title>

tried:
"/\<title.+\>(.+)\<\/title\>/i"
"/\<title\.*\>(.+)\<\/title\>/i"
"/\<title.*\>(.+)\<\/title\>/i"

??