Register now and start sharing your code snippets.
-->
Removing HTML tags from a string in Ruby
Ruby posted 6 months ago by marko
I don’t take credit for the regexp. The source for it is Mastering Regular Expressions by Jeffrey E.F. Frield.
1 def remove_html_tags 2 re = /<("[^"]*"|'[^']*'|[^'">])*>/ 3 self.title.gsub!(re, '') 4 self.description.gsub!(re, '') 5 end