title: Extract host name from URL using scala
body: <p>I have an RDD extracted from files containing source and destination URLS of the format :</p>
  
  <pre><code>google.de/2011/10/Extract-host       link.de/2011/10/extact-host
  facebook.de/2014/11/photos           facebook.de/2014/11/name.jpg
  community.cloudera.com/t5/           community.cloudera.com/t10/
  </code></pre>
  
  <p>These are the source and destination URLS.
  I would like to extract only the host name like for example:</p>
  
  <pre><code>google.de                   link.de
  facebook.de                 facebook.de
  community.cloudera.com      community.cloudera.com
  </code></pre>
  
  <p>I know how to extract the host name if there is only one column in the file using </p>
  
  <pre><code>file.flatMap(_.split("/").take(1)). 
  </code></pre>
  
  <p>Im not sure how to apply it on both source and destination URLs. 
  Here is what i have tried :</p>
  
  <pre><code>file.flatMap{case(src + "\t" +  dst) =&gt; 
  ((split.take(1).flatMap(line =&gt; line.split("/").take(1))),
  (split.takeRight(1).flatMap(line =&gt; line.split("/").take(1))))}
  </code></pre>
  
  <p>Please tell me how to extract this format using scala.</p>
  
  <p>Thank you!!</p>