title: Postgres - how to split and join?
body: <p>Is there a way to split a column into tokens, and join them (like you can in other programming languages such as Python, Java, Ruby)</p>
  
  <p>I have a column with urls such as "<a href="http://www.Yahoo.com" rel="nofollow">http://www.Yahoo.com</a>", and I want to extract "Yahoo.com" from it (the main domain, NOT the subdomain). The urls can be of the forms:</p>
  
  <ul>
  <li><a href="http://www.domain.com" rel="nofollow">http://www.domain.com</a></li>
  <li><a href="http://domain.com" rel="nofollow">http://domain.com</a></li>
  <li><a href="http://domain.com/page/page1" rel="nofollow">http://domain.com/page/page1</a></li>
  <li><a href="http://www.domain.com/" rel="nofollow">http://www.domain.com/</a></li>
  <li><a href="http://www.domain.com/page/page2" rel="nofollow">http://www.domain.com/page/page2</a></li>
  </ul>
  
  <p>I was planning on using a regex to extract everything after http:// and before the next slash. Then splitting the url by the period (.), then joining the last 2 tokens.</p>
  
  <p>With the regex, I can extract www.yahoo.com from <a href="http://www.yahoo.com" rel="nofollow">http://www.yahoo.com</a>. With the splits/joins, I can get yahoo.com from www.yahoo.com. Problem is I don't know how to do split/joins with Postgres.</p>
  
  <p>Anyone know of a way? Or better alternative?</p>