Remove HTTP:// and WWW from string
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/5782232/form-that-removes-www-and-prints-result-on-input">Form that removes WWW. and prints result on input?</a>  </p>
</blockquote>



<p>I'm using this code to remove WWW. from what the user types on an input box, however it works removing the first 4 characters so it doesn't work if the user submits <a href="http://www.example.com" rel="nofollow">http://www.example.com</a> or <a href="http://example.com" rel="nofollow">http://example.com</a>. </p>

<p>How do I look for the strings "www." and "http://" and remove them from input?</p>

<pre><code>&lt;input type="text" id="url" /&gt;
&lt;input type="button" id="submit" value="Go!" /&gt;

&lt;div id="output"&gt;&lt;/div&gt;

&lt;script&gt;
$("#submit").click(
    function() {
        var url = $("#url").val();

        if(url.match(/^www\./))
        {
            url = url.substring(4);
        }

        $("#output").html(url);
    }
);
&lt;/script&gt;
</code></pre>

<p>thanks</p>
