title: Get the last part of an url in Javascript
body: <p>Using the following URL example, how would I get the obtain the username from it?</p>
  
  <p><a href="http://www.mysite.com/username_here801" rel="nofollow">http://www.mysite.com/username_here801</a></p>
  
  <p>A regex solution would be cool.</p>
  
  <p>The following sample only gets the domain name:</p>
  
  <pre><code>  var url = $(location).attr('href');
  
    alert(get_domain(url));
  
    function get_domain(url) {
      return url.match(/http:\/\/.*?\//);
    }
  </code></pre>
  
  <p>jQuery solutions are also acceptable.</p>