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">wassup</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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With