実際、配列リストに 3 つ以上の単語を含むすべての html 要素を取得しようとしています。
$xp= new DomXPath($myhtmlpage);
近いけど違う!
$xp->query("/* my xpath expression + content +regex + count condition */");
方法は何ですか?
Not entirely fail-proof, but with XPath 1.0, there would be this rather ugly solution, here illustrated for matching p
elements containing at least 3 words in sequence "cat", "apple", "tree", "bottle"
.//p[
(
number(contains(., "cat")) +
number(contains(., "apple")) +
number(contains(., "tree")) +
number(contains(., "bottle"))
) >= 3
]
contains(., "word")
returning a boolean if context node contains desired wordnumber()