<title followed by anything not a > (in case there are attributes) followed by anything not a <, which we store in $1 followed by </title> i = case insensitive
Might need [^>]* instead of [^>]? but don't think so.
surrealillusions
6:26 pm on Feb 14, 2011 (gmt 0)
Found one that works. Seems kinda similiar to the one you've posted.
if(preg_match("/<title>(.+)<\/title>/i",$file,$m)) echo "$m[1]"; else echo "The page doesn't have a title tag";
rocknbil
6:07 pm on Feb 15, 2011 (gmt 0)
If it works ,it works, and yes, it is. :-) The only thing I would question is if it will slurp up more than you expect in some conditions. "." means "any character," + means "one or more," so "one or more of any character" could include < and /. This means "one or more of any character not a <"
[^<]+
So is a bit more specific. There is a possibility (however slim) there may be attributes inside <title> which is the only reasoning for the other bits there.