title: Top level domain from URL in C#
body: <p>I am using C# and ASP.NET for this.</p>
  <p>We receive a lot of &quot;strange&quot; requests on our IIS 6.0 servers and I want to log and catalog these by domain.</p>
  <p>Eg. we get some strange requests like these:</p>
  <ul>
  <li><a href="http://www.poker.winner4ever.example.com/" rel="nofollow noreferrer">http://www.poker.winner4ever.example.com/</a></li>
  <li><a href="http://www.hotgirls.example.com/" rel="nofollow noreferrer">http://www.hotgirls.example.com/</a></li>
  <li><a href="http://santaclaus.example.com/" rel="nofollow noreferrer">http://santaclaus.example.com/</a></li>
  <li><a href="http://m.example.com/" rel="nofollow noreferrer">http://m.example.com/</a></li>
  <li><a href="http://wap.example.com/" rel="nofollow noreferrer">http://wap.example.com/</a></li>
  <li><a href="http://iphone.example.com/" rel="nofollow noreferrer">http://iphone.example.com/</a></li>
  </ul>
  <p>the latter three are kinda obvious, but I would like to sort them all into one as &quot;example.com&quot; IS hosted on our servers. The rest isn't, sorry :-)</p>
  <p>So I am looking for some good ideas for how to retrieve example.com from the above. Secondly I would like to match the m., wap., iphone etc into a group, but that's probably just a quick lookup in a list of mobile shortcuts.I could handcode this list for a start.</p>
  <p>But is regexp the answer here or is pure string manipulation the easiest way? I was thinking of &quot;splitting&quot; the URL string by &quot;.&quot; and the look for item[0] and item[1]...</p>
  <p>Any ideas?</p>