Skip to content

Instantly share code, notes, and snippets.

@fjfish
Created August 22, 2013 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fjfish/6305130 to your computer and use it in GitHub Desktop.
Save fjfish/6305130 to your computer and use it in GitHub Desktop.
Remove all html (and probably xml) tags from an input string
def purge_tags taggy
taggy.gsub(/\<style.*?\<\/style\>/mi,'').gsub(/\<script.*?\<\/script\>/mi,'').
gsub(/<\/?[a-z][a-z0-9[:space:]]*[^<>]*>/, '').gsub( /&[^;]+;|[\r\n]/,'').
gsub( /[<>]*/, '').strip
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment