title: Got "two named subpatterns have the same name" when combining 2 regex into one
body: <p>I'm trying to combine 2 different regex with the same names into one and got the error message like this:</p>
  
  <blockquote>
    <p>Warning: preg_match(): Compilation
    failed: two named subpatterns have the
    same name at offset 276 ...</p>
  </blockquote>
  
  <p>One regex looks like this:</p>
  
  <pre><code>'%&lt;div class="artikkelen"&gt;[\s\S]*?&lt;h2&gt;(?P&lt;title&gt;[\s\S]*?)&lt;/h2&gt;%'
  </code></pre>
  
  <p>The other looks like this:</p>
  
  <pre><code>'%&lt;div id="article"&gt;[\s\S]*?&lt;h1&gt;(?P&lt;title&gt;[\s\S]*?)&lt;/h1&gt;%'
  </code></pre>
  
  <p>I could combine them in the following way without problem:</p>
  
  <pre><code>'%(&lt;div class="artikkelen"&gt;[\s\S]*?&lt;h2&gt;(?P&lt;title&gt;[\s\S]*?)&lt;/h2&gt;|&lt;div id="article"&gt;[\s\S]*?&lt;h1&gt;(?P&lt;title2&gt;[\s\S]*?)&lt;/h1&gt;)%'
  </code></pre>
  
  <p>But I don't like this way because I use 2 names. I'm wondering whether there is a better way to solve this problem. Thanks in advance.</p>
  
  <p>Best Regards,
  Box (boxoft...Simple &amp; Great)</p>