このような HTML コードがあるとします。内部にタグを<a href=""></a>
含まないすべてのタグを取得する必要があります。img
<a href="http://domain1.com"><span>Here is link</span></a>
<a href="http://domain2.com" title="">Hello</a>
<a href="http://domain3.com" title=""><img src="" /></a>
<a href="http://domain4" title=""> I'm the image <img src="" /> yeah</a>
この正規表現を使用して、すべてのタグ リンクを検索しています。
preg_match_all("!<a[^>]+href=\"?'?([^ \"'>]+)\"?'?[^>]*>(.*?)</a>!is", $content, $out);
次のように変更できます。
preg_match_all("!<a[^>]+href=\"?'?([^ \"'>]+)\"?'?[^>]*>([^<>]+?)</a>!is", $content, $out);
<img
しかし、内部に部分文字列を含む結果を除外するように指示するにはどうすればよい<a href=""></a>
ですか?