Today I Learned Remove HTML Tags Like a Regex Boss Strip HTML tags from your strings in Ruby with this Voodoo

Came across a slick little Ruby snippet to help remove HTML tags from a string. This helped in a Spina CMS project I am working on.

Aktagon provided a Ruby method to sanitize a string of HTML tags. I have a project I'm using Spina CMS, a Ruby on Rails content management system. I'll have a larger review on that repo in the future but this Regex was extremely in dropping some HTML tags within a text block in that project. I think this will come in handy again soon. Also, hats off to anyone that has a firm grasp of Regex. It's just Voodoo to me.

  def remove_html_tags
    re = /<("[^"]*"|'[^']*'|[^'">])*>/
    self.title.gsub!(re, '')
    self.description.gsub!(re, '')
  end