Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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(/<\/?[^>]*>/, "")
@ArtBears
Copy link

ArtBears commented Mar 31, 2016

This is great! Thanks for the gist =)

@matiasa18
Copy link

matiasa18 commented Aug 25, 2016

Thank you! 👍

@parag90-zz
Copy link

parag90-zz commented Dec 1, 2016

Thank you, Very useful !!

@v4vasanth
Copy link

v4vasanth commented Feb 24, 2017

Not all heroes wear capes

@meowsus
Copy link

meowsus commented Oct 29, 2017

@juryghidinelli
Copy link

juryghidinelli commented Apr 5, 2018

Thank you!

@illtellyoulater
Copy link

illtellyoulater commented Jul 26, 2020

👍

@Beyarz
Copy link

Beyarz commented Nov 24, 2020

This did the job!

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