title: Regex Negated Close/Open Tags
body: <p>Found quite a few links related but nothing in the area of how I want it. I want a Regular Expression to match a negated open and close tag. Take this string for example:</p>
  
  <pre><code>&lt;p&gt;This &lt;em&gt;is&lt;/em&gt; &lt;span&gt;a&lt;/span&gt; &lt;b&gt;sentence&lt;/b&gt;.&lt;/p&gt;
  </code></pre>
  
  <p>I use a regular expression to match <code>&lt;em&gt;</code> and <code>&lt;b&gt;</code> while leaving <code>&lt;p&gt;</code> and <code>&lt;span&gt;</code> alone. I do this using the following regular expression:</p>
  
  <pre><code>&lt;(?!p|span)[^&gt;]*&gt;
  </code></pre>
  
  <p>Problem is, the above will match <code>&lt;/p&gt;</code> and <code>&lt;/span&gt;</code>. I want to leave those end tags out as well. I've tried:</p>
  
  <pre><code>&lt;(/)?(?!p|span)[^&gt;]*&gt;
  </code></pre>
  
  <p>and different combinations of it but nothing I've tried works. Hoping I can get some help. How can I set a regular expression to match these <em>without</em> doing something like: <code>&lt;(?!p|span)[^&gt;]*&gt;(.*?)&lt;/(?!p|span)[^&gt;]*&gt;</code> (looks awful and probably takes more resources).</p>