title: Regex to find last occurrence with optional choice
body: <p>I have this string</p>
  
  <pre><code>&lt;p class="p1"&gt;lalala&lt;/p&gt;&lt;div&gt;&lt;div class="div2"&gt;&lt;div&gt;&lt;p&gt;lalala22&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
  </code></pre>
  
  <p>I want to find <code>&lt;div&gt;</code> or <code>&lt;div .*?&gt;</code> whichever the last one</p>
  
  <p>I tried with this regex</p>
  
  <pre><code>(&lt;div&gt;|&lt;div .*?&gt;)(?!.*(&lt;div&gt;|&lt;div .*?&gt;))
  </code></pre>
  
  <p>and</p>
  
  <pre><code>(&lt;div&gt;(?!.*&lt;div&gt;)|&lt;div .*?&gt;(?!.*&lt;div .*?&gt;))
  </code></pre>
  
  <p>but it will always end up finding <code>&lt;div class="div2"&gt;</code> instead of the last one which is <code>&lt;div&gt;</code></p>
  
  <p>How to solve this? How to use negative lookahead with optional choice like this?</p>
  
  <p>EDIT
  to make it clear, the end result of regex that I want is <code>&lt;div&gt;&lt;p&gt;lalala22&lt;/p&gt;&lt;/div&gt;</code>, that's why I want to find the last starting div tag</p>