Submitted by Damien on
Tags:
A little code snippet to let you remove HTML from any string in Ruby:
[source:ruby]
class String
# remove all HTML tags from the source string
def strip_html
self.gsub(/< \/?[^>]*>/, "")
end
end
[/source]
Then to run the code just do this:
[source:ruby]
blurb_html = "
Thanks for visiting our site.
"
blurb_text = blurb_html.strip_html
[/source]