Strip HTML in any string in Ruby

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]

Tags: 

Amazing PR thanks to Ryan Price

Mr Price, a well known figure in the Orlando, FL internet-savvy community, just promoted my search for employment on his community site's blog with many complimentary things to say. He also highlighted how through a limited amount of networking over the past year I've managed to gain a great deal number leads very quickly, which has just been an amazing experience - thanks to the feedback my family will be just fine.

Pages

Subscribe to Front page feed