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"
精彩评论