title: Regex with conditional html tag
body: <p>I need to write a Regex that captures whats inside a specific HTML tag:</p>
  
  <pre><code>&lt;span class="sentences"&gt;CAPTURE HERE&lt;/span&gt;
  </code></pre>
  
  <p>So I wrote, in C#:</p>
  
  <pre><code>&lt;span class=\"sentence\"&gt;((.|\\\\s)*?)&lt;/span&gt;
  </code></pre>
  
  <p>The problem I'm having and I'm not sure how to solve it, is that there is another span class inside that span that also ends with &lt;/span> and therefore is ending the capture on the wrong closing tag. How do I write a condition in a Regex that checks if there is another span class that is not "sentences" and if it does, that the capture should end on the next &lt;/span>?</p>
  
  <p>The input string on the Regex. </p>
  
  <pre><code>&lt;span class="sentence"&gt;O que a história da escravidão tem a dizer sobre &lt;span class="CharOverride-15"&gt;experiências religiosas&lt;/span&gt;?&lt;/span&gt;&lt;span class="sentence"&gt; Só silêncios,&lt;/span&gt;
  </code></pre>
  
  <p>What I want to ideally capture:</p>
  
  <pre><code>O que a história da escravidão tem a dizer sobre &lt;span class="CharOverride-15"&gt;experiências religiosas&lt;/span&gt;? Só silêncios,
  </code></pre>