php正则表达式怎样取的“内容”二字 要准确取得class="redarrow"下的 ,其他的都不要取
</span>内容<em class="redarrow"></em>

解决方案 »

  1.   

    '内容'二字在 class="redarrow"下?? 还是我看花了眼?
      

  2.   

    <span>xxx</span>信息<em class="kk"></em>
    <span>xxx</span>内容<em class="redarrow"></em>
    取“内容'二字
      

  3.   

    正则是神,程序猿嘛!
    于是你只要告诉他:只要被 > < 包括的就可以了
      

  4.   

    <?php
    $str=<<<HTML
    <span>xxx</span>信息<em class="kk"></em>
    <span>xxx</span>内容<em class="redarrow"></em>
    HTML;preg_match_all('/([^>]*)(?=<em\s+class="redarrow")/',$str,$matchs);
    print_r($matchs[1]);
      

  5.   

    取值很准确
    但是为何 传递值过去后啊 是 Array 啊?b.php //$tempCn 抓到的内容preg_match('/([^>]*)(?=<em\s+class="redarrow")/',$tempCn,$shuc);
    ob_start();
    header("Location:a.php?j=".$shuc[0]);
    ob_end_flush();
    ?>
    a.php<?php
    $sh=$_GET["j"]; 
    echo $sh;
    ?>显示的是 array   我自己写的正则式 虽然取值不准确 但传递过去之后能显示
    请大神指点迷津 错在哪里了?
      

  6.   

    preg_match('/([^>]*)(?=<em\s+class="redarrow")/',$tempCn,$shuc);
    print_r($shuc);
    exit();
    ob_start();
    header("Location:a.php?j=".$shuc[0]);
    ob_end_flush();
    看到什么? 有多个用preg_match_all
      

  7.   

    看到这个【  Array ( [0] => 扑街兔M_M [1] => 扑街兔M_M ) 】<?
    preg_match('/([^>]*)(?=<em\s+class="redarrow")/',$tempCn,$shuc);
    echo $shuc[1]
    ?>
    这样改能 看到这个 【    扑街兔M_M   】但重定向 传递回去后 就是空值
    不懂怎么回事
      

  8.   

    我抓 <title>标签内的 内容 就可以了 重定向传递也 能显示 应该是 正则式的问题
      

  9.   

    php正则表达式怎样取的“内容”二字  ???
      

  10.   

    不可能吧。你都看到[0] = 扑街兔M_M 了。传[0]的值的话不可能是array啊上完整代码。