title: Extract hostname name from string
body: <p>I would like to match just the root of a URL and not the whole URL from a text string. Given: </p>
  
  <pre class="lang-none prettyprint-override"><code>http://www.youtube.com/watch?v=ClkQA2Lb_iE
  http://youtu.be/ClkQA2Lb_iE
  http://www.example.com/12xy45
  http://example.com/random
  </code></pre>
  
  <p>I want to get the 2 last instances resolving to the <code>www.example.com</code> or <code>example.com</code> domain. </p>
  
  <p>I heard regex is slow and this would be my second regex expression on the page so If there is anyway to do it without regex let me know.</p>
  
  <p>I'm seeking a JS/jQuery version of this solution.</p>