title: Javascript [\s\S]* is too greedy
body: <p>I have a sample multi line string where in I have to get all the div tags and contents between them where in the p tag is not equal to a specific id</p>
  
  <pre><code>var str="&lt;div&gt;
           &lt;p id=\"a\"&gt;Sample sentence&lt;/p&gt;
           &lt;/div&gt;
  
           &lt;div&gt;
           &lt;p id=\"b\"&gt;Sample sentence 2&lt;/p&gt;
           &lt;/div&gt;"
  </code></pre>
  
  <p>The regex that I was using was too greedy, I only need to match the 2nd div tag and its content but it is also capturing the div tag from above. Here is my regex:</p>
  
  <pre><code>&lt;div&gt;[\s\S]*&lt;p id="b"&gt;[\s\S]*&lt;\/div&gt;
  </code></pre>
  
  <p>for the regex I used it is capturing the entire string but I just want to capture:</p>
  
  <pre><code>&lt;div&gt;
    &lt;p id="b"&gt;Sample sentence 2&lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>any regex guru out there that can help me out with this?</p>