title: Regex for Encoded HTML
body: <p>I'd like to create a regex that will match an opening <code>&lt;a&gt;</code> tag containing an href attribute only:</p>
  
  <pre><code>&lt;a href="doesntmatter.com"&gt;
  </code></pre>
  
  <p>It should match the above, but not match when other attributes are added:</p>
  
  <pre><code>&lt;a href="doesntmatter.com" onmouseover="alert('Do something evil with Javascript')"&gt;
  </code></pre>
  
  <p>Normally that would be pretty easy, but the HTML is encoded. So encoding both of the above, I need the regex to match this:</p>
  
  <pre><code>&amp;#60;a href&amp;#61;&amp;#34;doesntmatter.com&amp;#34; &amp;#62;
  </code></pre>
  
  <p>But not match this:</p>
  
  <pre><code>&amp;#60;a href&amp;#61;&amp;#34;doesntmatter.com&amp;#34; onmouseover&amp;#61;&amp;#34;alert&amp;#40;&amp;#39;do something evil with javascript.&amp;#39;&amp;#41;&amp;#34; &amp;#62;
  </code></pre>
  
  <p>Assume all encoded HTML is "valid" (no weird malformed XSS trickery) and assume that we don't need to follow any HTML sanitization best practices. I just need the simplest regex that will match A) above but not B).</p>
  
  <p>Thanks!</p>