title: Get the subdomain from a URL
body: <p>Getting the subdomain from a URL sounds easy at first.</p>
  
  <pre><code>http://www.domain.example
  </code></pre>
  
  <p>Scan for the first period then return whatever came after the "http://" ...</p>
  
  <p>Then you remember</p>
  
  <pre><code>http://super.duper.domain.example
  </code></pre>
  
  <p>Oh. So then you think, okay, find the last period, go back a word and get everything before! </p>
  
  <p>Then you remember</p>
  
  <pre><code>http://super.duper.domain.co.uk
  </code></pre>
  
  <p>And you're back to square one. Anyone have any great ideas besides storing a list of all TLDs?</p>