http://henrik.nyh.se/2007/03/03/using-gsub-with-blocks-to-strip-attributes-from-html-tags/
html = 'Getting <a href="#" id="foo">rid</a> of <code id="bar">idattributes, but not in text: id="not this".'
html.gsub(/<(.*?)>/) {|innards| innards.gsub(/ id=("|').*?\1/, '') }
# => Getting rid of
id attributes, but not in text: id="not this".