Php 在WordPress中选择和删除带有特定关键字的标记

Php 在WordPress中选择和删除带有特定关键字的标记,php,wordpress,rss,ads,autoblogged,Php,Wordpress,Rss,Ads,Autoblogged,我使用了一个自动博客插件,它允许我聚合某些站点的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=

我使用了一个自动博客插件,它允许我聚合某些站点的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中替换或删除它


谢谢

如果您想删除包含关键字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>";

Regexp将是您在这里需要的工具。@ohgoodwhy很棒,工具hs Regexp Search and Replace tool。。。在搜索和替换中键入什么?纯文本搜索和替换还有另一个选项AutoBlogged工具使用正则表达式或纯文本进行搜索和替换。在这种情况下,如何用空格或空值替换这些行?