title: youtube channel ID or name from URL
body: <p>I'd like to get a youtube channel ID or name from a youtube URL with a single regex.
  URLs can be vary like:</p>
  <p>(#1 .../c/{name}) <code>https://www.youtube.com/c/aespa</code> or</p>
  <p>(#2 .../{name}) <code>http://www.youtube.com/GIRLSGENERATION</code> or</p>
  <p>(#3 .../channel/{ID}) <code>https://www.youtube.com/channel/UCzgxx_DM2Dcb9Y1spb9mUJA/featured</code></p>
  <p>What I already have now is do the job for case #1 and #3:</p>
  <pre><code>preg_match('/(?:(?:http|https):\/\/)?(?:www\.)?(?:youtube\.com)\/(channel|c)\/(?&lt;name&gt;[A-Za-z0-9-_\.]+)/im', $url, $matches);
  </code></pre>
  <p>I'd be great if the <code>/channel|c</code> part could be optional so the case #2 will work too. It might be a problem that regex must check for <code>/channel|c</code> first, and if there is no matches, it should check the URL against the <code>/channel|c</code> part (Otherwise, <code>/c</code> or <code>/channel</code> string will be considered as <em>name</em> parameter).</p>
  <p>Any advise appreciated!</p>