我用的代码是:preg_match("/<head>(.*)<\/head>/i",$content, $matches);
匹配不到任何内容而用
eregi("<head>(.*)</head>",$content, $matches);
则能抓到<head></head>之间的内容谁能给出preg_match抓取<head></head>之间的内容的正则。

解决方案 »

  1.   

    to helloyou0
    能说具体点吗?
    preg_match("/<head>(.*)<\/head>/mi",$content, $matches);
    是这样吗?经测试还是不行啊。
      

  2.   


    require_once("snoopy.class.php");
    $snoopy = new Snoopy;
    $url="http://www.sina.com.cn";
    $snoopy->fetch($url);
    $content = $snoopy->results;
    preg_match("/<head>(.*)<\/head>/i",$content, $matches);
    print_r($matches);总是抓不到东西,页面光光的,查看原码也是空的。
      

  3.   

    require_once("snoopy.class.php");
    $snoopy = new Snoopy;
    $url="http://www.sina.com.cn";
    $snoopy->fetch($url);
    $content = $snoopy->results;
    preg_match("/<head>(.*?)<\/head>/is",$content, $matches);//这样应该可以了
    print_r($matches);
      

  4.   

    感谢 amani11
    能讲一下为什么吗
    为什么/i和/isu不行,而/is却可以呢
      

  5.   

    知道原因了,结贴给分。
    感谢 amani11 同学