Skip to content

Instantly share code, notes, and snippets.

@awesome
Created November 3, 2009 16:29
Show Gist options
  • Star 25 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save awesome/225181 to your computer and use it in GitHub Desktop.
Save awesome/225181 to your computer and use it in GitHub Desktop.
ruby strip HTML tags
# copied from (thanks!): http://codesnippets.joyent.com/posts/show/615
str = <<HTML_TEXT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
<h1>Application error</h1>
<p>Change this error message for exceptions thrown outside of an action (like
in Dispatcher setups or broken Ruby code) in public/500.html</p>
</body>
</html>
HTML_TEXT
puts str.gsub(/<\/?[^>]*>/, "")
@Beyarz
Copy link

Beyarz commented Nov 24, 2020

This did the job!

@JonRamSage
Copy link

lovely - just perfect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment