title: Regex: Match html tag only if it contains a specific class id
body: <p>Match an html tag using perl regex in php. </p>
  
  <p>Want the tag to match if it contains "class=details" somewhere in the open tag.</p>
  
  <p>Wanting to match <code>&lt;table border="0" class="details"&gt;</code> not <code>&lt;table border="0"&gt;</code></p>
  
  <p>Wrote this to match it:</p>
  
  <pre><code>'#&lt;table(.+?)class="details"(.+?)&gt;#is'
  </code></pre>
  
  <p>The <code>&lt;table(.+?)</code> creates a problem since it matches the first table tag it finds only stopping the match when it finds <code>class="details"</code> no matter how far down the code it occurs. </p>
  
  <p>I think this logic would fix my problem: </p>
  
  <p>"Match <code>&lt;table</code> but only if it contains <code>class="details"</code> before the next <code>&gt;</code>"</p>
  
  <p>How can I write this?</p>