...text...</span>" />
开发者

regex to strip all html tags except span tag

I am trying to remove all the html from a string except

<span class="match">...text...</span>

Suppose if a string is "<p>Hello there</p><span class="match">wassup</span>"

I just need "Hello there<span class="match">w开发者_开发百科assup</span>"

Can anybody help? I am doing it in ruby (rails)


ActionView::Helpers provides the sanitize method to do this.

http://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-sanitize

sanitize "some html", :tags => %w"span"
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜