0

我使用一个自动博客插件,它允许我聚合来自某些站点的 RSS 提要,以在我不发帖时填补我博客中的空白,这个想法是在帖子中注入广告,例如带有随机动态链接的 AdSense URL,但通常以某些 URL,这是一个代码片段:

src="http://rss.feedsportal.com/c/669/f/9809/s/3b7b71e8/sc/5/mf.gif" border="0" /><br clear='all'/><br /><br /><a href="http://da.feedsportal.com/r/199108411625/u/49/f/9809/c/669/s/3b7b71e8/sc/5/rc/1/rc.htm" rel="nofollow"><img src="http://da.feedsportal.com/r/199108411625/u/49/f/9809/c/669/s/3b7b71e8/sc/5/rc/1/rc.img" border="0" /></a><br /><a href="http://da.feedsportal.com/r/199108411625/u/49/f/9809/c/669/s/3b7b71e8/sc/5/rc/2/rc.htm" rel="nofollow"><img src="http://da.feedsportal.com/r/199108411625/u/49/f/9809/c/669/s/3b7b71e8/sc/5/rc/2/rc.img" border="0" /></a><br /><a href="http://da.feedsportal.com/r/199108411625/u/49/f/9809/c/669/s/3b7b71e8/sc/5/rc/3/rc.htm" rel="nofollow"><img src="http://da.feedsportal.com/r/199108411625/u/49/f/9809/c/669/s/3b7b71e8/sc/5/rc/3/rc.img" border="0" /></a><br /><br /><a href="http://da.feedsportal.com/r/199108411625/u/49/f/9809/c/669/s/3b7b71e8/sc/5/a2.htm"><img src="http://da.feedsportal.com/r/199108411625/u/49/f/9809/c/669/s/3b7b71e8/sc/5/a2.img" border="0" /></a><img width="1" height="1" src="http://pi.feedsportal.com/r/199108411625/u/49/f/9809/c/669/s/3b7b71e8/sc/5/a2t.img" border="0" /><img src="http://feeds.feedburner.com/~r/techradar/allnews/~4/tWczqbBA1yg" height="1" width="1" /><br />

所有注入的标签都包含“*feedsportal.com”的想法,我如何选择包含该术语的整个标签行并在 WordPress 中替换或删除它?

谢谢!

4

1 回答 1

0

如果您想删除所有包含关键字 feedsportal.com 的标签,您可以尝试这样的操作。

// Replace all matches
$str = preg_replace("/\<a.*?feedsportal\.com.*?\>.*?\<\/a\>/is","",$str);

// Collect matches
preg_match_all("/\<a.*?feedsportal\.com.*?\>.*?\<\/a\>/is",$str,$matches);

// Show matches
print "<pre>";
print_r($matches);
print "</pre>";
于 2014-06-14T01:13:54.160 回答