title: Remove HTML elements containing no characters or &nbsp;
body: <p>I'm working with some generated <code>HTML</code>, from a Word document, where I would like to extract <em>only</em> paragraph elements containing fully capitalized characters, <em>and</em> that do not contain only "empty elements" or <code>&amp;nbsp;</code>. I'm currently using <code>javascript</code> / <code>jquery</code> and <code>regex</code> to determine what <code>&lt;p class="foo"&gt;</code> elements to extract - please see the snippet: </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var allCaps = /^(?=.{1})(\s*[A-Z,\s]+\s*$)/,
      whitespace = /^|s+$/, 
      cont = $('&lt;div class="container"&gt;'),
      elems = $('p[class^="foo"]');
  
  elems.each(function(){
    var txt = $(this).first().text();
    if(allCaps.test(txt)){
      if(whitespace.test(txt)){
        var copy = cont.clone();
        var cln = $(this).clone();
        copy.append(cln);
        $('body').append(copy);
      }
    }
  });
      </code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.container{
    padding: 5px;
    border: solid 2px steelblue;
    background-color: pink;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;p class="foo"&gt;I INTRODUCTION&lt;/p&gt;
  &lt;p class="foo"&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
  &lt;!-- THIS ELEMENT IS BEING COPIED --&gt;
  &lt;p class="foo"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/p&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>You'll notice that the third <code>foo</code> paragraph is included in the <code>allCaps</code> and <code>whitespace</code> tests because of the <code>&amp;nbsp;</code>. Is there any way I can exclude it? In other words, is there a regex, or other method, that can be used to capture just the first <code>foo</code> in the snippet example?</p>