Skip to content

Instantly share code, notes, and snippets.

@awesome
Created November 3, 2009 16:29
Show Gist options
  • 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(/<\/?[^>]*>/, "")
@meowsus
Copy link

meowsus commented Oct 29, 2017

@juryghidinelli
Copy link

Thank you!

@illtellyoulater
Copy link

👍

@Beyarz
Copy link

Beyarz commented Nov 24, 2020

This did the job!

@JonRamSage
Copy link

lovely - just perfect

@reiz
Copy link

reiz commented Oct 1, 2024

Awesome!

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