public static string GetDomain(string s) { string host = s; string[] arr = host.Split('.'); if (arr.Length < 3 || RegExp.IsIP(host)) { return(host); } string domain = host.Remove(0, host.IndexOf(".") + 1); if (domain.StartsWith("com.") || domain.StartsWith("net.") || domain.StartsWith("org.") || domain.StartsWith("gov.")) { return(host); } return(domain); }