$s = "http://abc.efg.yahoo.com";
preg_match("/\.([^.]+?)\.com/is",$s,$m);
echo $m[1];