title: How to strip http:// and www. from an entered domain name using c#
body: <p>In the application I am working on, we allow user to enter a list of domain names, we expect the user to enter the domain names in any on the following formats</p>
  
  <ul>
  <li><a href="http://www.stackoverflow.com">stackoverflow.com</a></li>
  <li><a href="http://www.stackoverflow.com">www.stackoverflow.com</a></li>
  <li><a href="http://www.stackoverflow.com">http://stackoverflow.com</a></li>
  <li><a href="http://www.stackoverflow.com">http://www.stackoverflow.com</a></li>
  </ul>
  
  <p>but when storing this domain names back into our databases, we want to store the domain name in the following format only</p>
  
  <p><strong>Format : stackoverflow.com</strong></p>
  
  <p>So wanted to know if there is a ready made helper that I can use to get this job done, or any suggestions to do this in an efficient manner.</p>
  
  <p><strong><a href="http://mattgemmell.com/2008/12/08/what-have-you-tried/" rel="nofollow">What have I tried ?</a></strong></p>
  
  <p>This is what I came up with,</p>
  
  <pre><code>public static string CleanDomainName(string domain)
  {
      domain = domain.Trim();
      if (domain.Split('.').Count() &gt; 2)
      {
          domain = domain.Split('.')[1] + "." + domain.Split('.')[2];
      }
      return domain;
  }
  </code></pre>
  
  <p>Please help me out on this.</p>