title: regex for Ebuild File Format
body: <p>I am trying to parse the Ebuild File Format based on <a href="https://devmanual.gentoo.org/ebuild-writing/file-format/index.html" rel="nofollow noreferrer">File Naming Rules</a>.</p>
  
  <p>Until now I came up with:</p>
  
  <pre><code>(?P&lt;name&gt;[a-z0-9_-]+)-(?P&lt;major&gt;[0-9]+)(\.(?P&lt;minor&gt;[0-9]+))?(\.(?P&lt;micro&gt;[0-9]+))?(?P&lt;release&gt;(_alpha|_beta))*(?P&lt;status&gt;(_pre|_rc\d+|_p\d+))(?P&lt;revision&gt;-r\d+)*
  </code></pre>
  
  <p>which doesn't do the job (<a href="https://regex101.com/r/uF7CAD/4" rel="nofollow noreferrer">Regex examples</a>).</p>
  
  <p>I am unhappy, that my version expression contains the <code>.</code> in the group match and  <em>release</em> contains the char <code>_</code> in the match. In addition the <em>revision</em> finds '-r' chars instead of returning the number it self. </p>
  
  <p>How could I fix my regular expression?</p>