$regb2 = '\<h3 class\=\"t\"\>(.*)\<\/h3\>';
preg_match_all("/$regb2/is", $ruleb1[0],$ruleb2);
print_r($ruleb2); 只取到了一个h3 请问是什么原因
preg_match_all("/$regb2/is", $ruleb1[0],$ruleb2);
print_r($ruleb2); 只取到了一个h3 请问是什么原因
<table><h3>...</h3></table>
<table><h3>...</h3></table>
<table><h3>...</h3></table>
<table><h3>...</h3></table>还是只取到了第一个 不加? 取到第一个 下面的几个table都能取到 加了 就取到第一个h3
<table><h3 class="t">...</h3></table>
<table><h3 class="t">...</h3></table>
<table><h3 class="t">...</h3></table>
<table><h3 class="t">...</h3></table>';$regb2 = '\<h3 class\=\"t\"\>(.*?)\<\/h3\>';
preg_match_all("/$regb2/is", $str,$ruleb2);print_r($ruleb2);
匹配到5个Array
(
[0] => Array
(
[0] => <h3 class="t">...</h3>
[1] => <h3 class="t">...</h3>
[2] => <h3 class="t">...</h3>
[3] => <h3 class="t">...</h3>
[4] => <h3 class="t">...</h3>
) [1] => Array
(
[0] => ...
[1] => ...
[2] => ...
[3] => ...
[4] => ...
))
$str = "<table><h3>a</h3></table>
<table><h3>b</h3></table>
<table><h3>c</h3></table>
<table><h3>d</h3></table>
<table><h3>e</h3></table>
";
$pattern = '/\<h3\>(.*?)\<\/h3\>/';
preg_match_all($pattern, $str, $matches);
echo '<pre>';
print_r($matches);
?>
echo '网站加载成功...';$regb = '\<div id\=\"container\"\>(.*)\<\/div\>';
preg_match("/$regb/is", $objb,$ruleb);
$regb1 = '\<table cellpadding\=\"0\" cellspacing\=\"0\" class\=\"result\" id\=\"\d\" \>(.*)\<\/table\>';
preg_match("/$regb1/is", $ruleb[0],$ruleb1);
$regb2 = '\<h3 class\=\"t\"\>(.*?)\<\/h3\>';
preg_match_all("/$regb2/is", $ruleb1[0],$ruleb2);
print_r($ruleb2[0]);加?号是取消贪婪模式了 我这经过了几层子模式 你看是不是上面那里有问题 还是网站里有相似的标签导致的问题