Using the following URL example, how would I get the obtain the username from it?
http://www.mysite.com/username_here801
A regex solution would be cool.
The following sample only gets the domain name:
var url = $(location).attr('href');
alert(get_domain(url));
function get_domain(url) {
return url.match(/http:\/\/.*?\//);
}
jQuery solutions are also acceptable.
http://jsfiddle.net/5LHFd/
To always return the text directly after the slash that follows the .com you can do this:
http://jsfiddle.net/5LHFd/2/