i have a sting that contains http://example.com/user/9800, i want to be able to get the domain name(http://example.com) from this string regardless of the length of the string. See explanation below
var string = "http://example.com/user/9800";
or
var string ="http://www.example.com/user/8399";
new string
var new string = "http://example.com";