I think the
Uri
class can be used to extract the
Host
name from the
url
string, it can be split up with
'.'
and the first word which does not match the exempted strings can be taken as shown below
string[] urls = {@"https://WWW.facebook.com/pages/Delhi/Shemrock-Chain-of-Preschools/359534360364",
@"http://twitter.com/#!/ShemrockGroup",
@"http://www.youtube.com/user/shemrocknurseryrhyme"};
foreach(string url in urls)
Console.WriteLine (((new Uri(url)).Host).Split('.')
.FirstOrDefault(str => !@"www mail".Contains(str.ToLower())) ?? string.Empty);