【发布时间】:2014-07-20 09:23:42
【问题描述】:
$html = '<html>
<body>
<div id="dupe_1">1
<div class="dupe_1.1">1.1</div>
<div id="dupe_1.2">1.2</div>
</div>
<div id="dupe_2">2
<div class="dupe_2.1">2.1</div>
<div id="dupe_2.2">2.2</div>
<div>extra</div>
</div>
</body>
</html>';
$html = phpQuery::newDocumentHTML($html);
$node = pq('div:regex(id,^dupe_\d+$)',$html);
echo count($node);
这将返回 7,即所有 div。它应该只返回 2 个 div(dupe_1 和 dupe_2)
【问题讨论】:
-
我在 phpQuery 选择器文档 code.google.com/p/phpquery/wiki/Selectors 中没有看到
:regex -
@Barmar 我猜它有一个实现。如果没有,您可以建议解决方法。