开发者

remove <font> tag using hpricot

开发者 https://www.devze.com 2023-01-02 01:03 出处:网络
the html like this: \"[font color=\"#FF0000\"]test [font color=\"#FF0000\"]Hello world[/font][/font]\"

the html like this:

"[font color="#FF0000"]test [font color="#FF0000"]Hello world[/font][/font]"

I want to replace the font tag the result like this:

test Hello worl开发者_如何转开发d

thanks you


Just do doc.inner_text with hpricot

Sure it will remove all tags. Not only <font>.


doc.search("font").remove?


If you want to remove html and only want text USE

string = "<font color='#FF0000'>test <font color='#FF0000'>Hello world</font></font>"
strip_tags(string)
0

精彩评论

暂无评论...
验证码 换一张
取 消