$str = '<a href="filename.php?query=string" target="_blank">测试</a>';
$re  = "|href=([\"\']?)(\w+)\.php\?(.+)\\1 (.+)>(.+)<|isU";preg_match($re,$str,$out);
print_r($out);

解决方案 »

  1.   

    楼上的不完全对,取得的$out[1] = "
    而且不能取得
    <a href=filename.php>
    <a href="filename.php" target=.....>
    <a href = filename.php.....>
    等等情况。另问一句,你那个\\1什么意思?
      

  2.   

    filname.php两边有 * 个空格。是用有("|')或没有包围的。
    "和'的包围中间有* 个空格
    有或没有queryString即(?即?后的东西)
    有或没有其他比如target信息
    最后一个>之前有 * 个空格<a href="xxx.php">xx
    <a href='xxx.php'>xxx
    <a href ="xxx.php" >xxxx
    <a   href= xxx.php >xxxxx
    <a href=xx.php?>
    <a href=xx.php?query...>
    <a href=xx.php?query... target... >
    ...............
    等等情况了。