title: Conditionally Strip HTML Node - Regexp/gsub
body: <p>I want to generate a search preview of an article by removing certain html nodes including the child node(s) (particularly headers and images) and removing all other tags eg. paragraph while leaving child nodes.</p>
  
  <p>e.g.</p>
  
  <pre><code>"&lt;h2&gt;Subject&lt;/h2&gt;&lt;p&gt;Subject is the who, what, where, why and when.&lt;/p&gt;".gsub(/&lt;\/?[^&gt;]*&gt;/, '')
  </code></pre>
  
  <p>results in</p>
  
  <pre><code>Subject Subject is the who, what, where, why and when.
  </code></pre>
  
  <p>however I require</p>
  
  <pre><code>Subject is the who, what, where, why and when.
  </code></pre>
  
  <p>I'm using the Rails plugin <a href="http://github.com/flavorjones/loofah" rel="nofollow noreferrer">Loofah</a> to sanitize user input and this works great; in fact I can define a scrubber to do this however it seems that a regexp would be sufficient for this simple operation. </p>
  
  <p>Thanks in advance for any advice.</p>