re = /(<(?![\/]?a)(?![\/]?img)([^>]+)>)/
str = '<!-- The line could look like this -->
<td align=right valign=bottom nowrap><div>January 24, 2013 </div></td>
<!-- Or this -->
<div>Is this system supported? </div>
<div>Is this system supported?</div>
<div><a href="game.com"></a><p>Test</p></div>
<!-- Even this -->
<span>This is a span tag </div>
<img src="example.com/example.jpg">
<img src="smiley.gif" alt="Smiley face" height="42" width="42">
<img src="example.com/example.jpg">
<a href="game.com"></a>
<div id="example"><img src="example.com/example.jpg">Hello World<a href="game.com"></a></div>'
subst = ''
result = str.gsub(re, subst)
# Print the result of the substitution
puts result
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html