title: PHP- Recursive Regex to get complete Div Class with it's inner content
body: <p>I have searched but cannot find a solution that works.  I have tried using DOM but the result is not identical (different spaces and tag elements - minor differences but I need identical for further pattern searches on the source) to the source, hence I would like to try regex.  Is this possible (I know it isn't best solution but would like to try it)?  For example is it possible to return all of the div class &quot;want-this-entire-div-class&quot; including inner:</p>
  <pre><code>$html = '&lt;div class=&quot;not-want&quot;&gt;
          &lt;div class=&quot;also-not-want&quot;&gt;
      &lt;div class=&quot;want-this-entire-div-class&quot;&gt;
  &lt;button class=&quot;dropdown-toggle search-trigger&quot; data-toggle=&quot;dropdown&quot;&gt;&lt;/button&gt;
  &lt;div class=&quot;dropdown-menu j-dropdown&quot;&gt;
  &lt;div class=&quot;header-search&quot;&gt;
          &lt;input type=&quot;text&quot; name=&quot;search&quot; value=&quot;&quot; placeholder=&quot;Search entire site here...&quot; 
  class=&quot;search-input&quot; data-category_id=&quot;&quot;/&gt;
    &lt;button type=&quot;button&quot; class=&quot;search-button&quot; data-search-url=&quot;https://www.xxxxcom/index.php? 
  route=product/search&amp;amp;search=&quot;&gt;&lt;/button&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class=&quot;not-want-this-also&quot;&gt;
  &lt;div class=&quot;or-this&quot;&gt;';
  </code></pre>
  <p>The following stops after the first div&gt;</p>
  <p>preg_match('/&lt;div class=&quot;want-this-entire-div-class&quot;(.*?)&lt;/div&gt;/s', $html, $match);
  Thanks</p>