php preg_match_all() 取消子模式

<?php
header("Content-type:text/html;charset=utf-8");
  //取消子模式
  $string='<td><a href="http://www.baidu.com">百度</a></td>';php

  $preg='/<td><a href="([\s\S]*?)">([\s\S]*?)<\/a><\/td>/';html

  if(preg_match_all($preg,$string,$matches)){
      var_dump($matches[0]);
      echo "<br/>";
     var_dump($matches[1]);
      echo "<br/>";
      var_dump($matches[2]);
  }else{
   echo "沒有匹配到";
  } 
?>spa

對比:htm

<?php
header("Content-type:text/html;charset=utf-8");
//取消子模式
$string='<td><a href="http://www.baidu.com">百度</a></td>';utf-8

$preg='/<td><a href="(?:[\s\S]*?)">([\s\S]*?)<\/a><\/td>/';get

if(preg_match_all($preg,$string,$matches)){
var_dump($matches[0]);
echo "<br/>";
var_dump($matches[1]);
}else{
echo "沒有匹配到";
}
?>string

取消子模式----->?:百度

相關文章
相關標籤/搜索