Function to erase substrings and explode string?
<p>I want to replace "http://" "https://" "www." and also explode the url on "/".</p>

<p>For example: <a href="http://www.google.com/whatever" rel="nofollow">http://www.google.com/whatever</a> should return google.com</p>

<p>I was doing as much as I knew how on this function:</p>

<pre><code>// Change site's title
function changeTitle(url) { 
    var title = url.replace("http://", ""); // 1
    title = title.replace("https://", ""); // 2
    title = title.replace("www.", ""); // 3
    document.title = title; 
}
</code></pre>

<p>But I want to do all the process on a separate function, e.g: <code>function cleanUrl(url)</code>. I tried this and variants but couldn't make it work:</p>

<pre><code>// Clean URL
function cleanUrl(url) { 
    var title = url.replace("http://", ""); 
    title = title.replace("https://", ""); 
    title = title.replace("www.", ""); 
}

// Change site's title
function changeTitle(url) { 
    cleanUrl(url);
    document.title = title; 
}
</code></pre>

<p>How do I do it? Also I'm not exploding the url since I didn't know how.</p>
