/href=(.+?)(?:\s[^\>]*?>)(.+?)<\/a>/is$out[1][0] = xxxxxx1
$out[1][1] = xxxxxx2
.....
$out[2][0] = body1
$out[2][1] = body2
.....

解决方案 »

  1.   

    好像不对也,得到的结果是
    href=xxxxxx1 target=ttt class=xxxx                body1
    href=xxxxxx2 target=ttt                           Body2
      

  2.   

    I tested and got the result I wrote above.
      

  3.   

    He is right I has tested it yesterday<?php
    /**
    功能:提取字符串
    @$string 传入的要提取的字符串
    @return  需要的字符数组
    */
    function rzs($string)
    {
    $pattern = "/href=(.+?)(?:\s[^\>]*?>)(.+?)<\/a>/is";
    preg_match_all($pattern, $string, $out, PREG_SET_ORDER);
    return $out;
    }
    $a = "<a href=xxxxxx1 target=ttt class=xxxx>body1</a><a href=xxxxxx2 target=ttt222>body2</a>";
    $c =  rzs($a,"");
    ?>
    <TEXTAREA NAME="" ROWS="6" COLS="70"><?php echo $a;?></TEXTAREA>
    <TEXTAREA NAME="" ROWS="6" COLS="70"><?php print_r($c);?></TEXTAREA>