For Example I have this string
http://www.merriam-webster.com/dictionary/sample
What I want is to return only merriam-webster.com
I'm planning to use .Replace()
but I think there are better approach for this question.
If you are working for Winforms then
string url = "http://www.merriam-webster.com/dictionary/sample";
UriBuilder ub = new UriBuilder(url);
MessageBox.Show(ub.Host.Replace("www.",""));
and for web,
Get host domain from URL?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With