选择特定标签 [英] selecting specific tag

查看:76
本文介绍了选择特定标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个在我的网站上显示RSS源的脚本。要做

,我想把所有< div class =" blabla">< img src =" bla.jpg"

alt = " BLA"> < / DIV>标签并将它们放在我的文本前面。所以

跟随字符串:


< p>这是文本blah blah blah< / p>

< div class =" blabla">< img src =" bla.jpg" ALT =" BLA"> < / div>

< p>这是另一个文字< / p>


应该作为输出:


< div class =" blabla">< img src =" bla.jpg" ALT =" BLA"> < / div>

< p>这是文本blah blah blah< / p>

< p>这是另一个文本< / p>

我尝试使用正则表达式,但我并没有真正完成它。这里

是我使用的代码:

while(ereg(''/< DIV class = \" blabla \" *>(。* ?)< \ / DIV> / i'',$ content,$ matches)){

$ img = $ img。$匹配[0];

$ content = ereg_replace(''/< DIV

class = \" imgbar50 \" *>(。*?)< \ / DIV> / i'', ",$ content,1);

}


我做错了什么?

I am making a script which displays an RSS feed on my website. To do
this I would like to take all the <div class="blabla"><img src="bla.jpg"
alt="bla"> </div> tags and put them in front of my text. So the
following string:

<p>This is text blah blah blah</p>
<div class="blabla"><img src="bla.jpg" alt="bla"> </div>
<p>this is another text</p>

should give as output:

<div class="blabla"><img src="bla.jpg" alt="bla"> </div>
<p>This is text blah blah blah</p>
<p>this is another text</p>
I tried using regular expressions, but I do not really get it done. Here
is the code I use:
while(ereg(''/<DIV class=\"blabla\"*>(.*?)<\/DIV>/i'',$content, $matches)){
$img=$img.$matches[0];
$content=ereg_replace(''/<DIV
class=\"imgbar50\"*>(.*?)<\/DIV>/i'',"",$content,1);
}

what do i do wrong?

推荐答案

content,


matches)){
matches)){


img =

这篇关于选择特定标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆