title: Capture possible MIME Trees with Regex
body: <p>I'm trying to make a capture group to grab the tree portion of a MIME type. i already know that the input text is a MIME type. As examples:</p>
  
  <p><code>MIME Type                               Matched portion</code></p>
  
  <pre><code>text/plain                           -&gt; No match
  application/x-deb                    -&gt; "x"
  application/vnd.google-earth.kml+xml -&gt; "vnd"
  application/x.example123             -&gt; "x"
  application/prs.vanity               -&gt; "prs"
  application/prs-vanity               -&gt; No match
  </code></pre>
  
  <p>Currently, I have <code>/(?:(prs|vnd|x)\.)|(x-)?</code>, but I'm trying to consolidate it into a single capture group. Is this possible?</p>
  
  <p>The only other try I've done is <code>/(?:(prs|vnd|x)[\.-])?</code>, but that matches, for example, <code>application/vnd-badly-made</code> as <code>vnd</code> instead of properly not matching anything.</p>