title: parse string value from a URL using c#
body: <p>I have a string "<a href="http://site1/site2/site3" rel="nofollow noreferrer">http://site1/site2/site3</a>". I would like to get the value of "site2" out of the string. What is the best algorythm in C# to get the value. (no regex because it needs to be fast). I also need to make sure it doesn't throw any errors (just returns null).</p>
  
  <p>I am thinking something like this:</p>
  
  <pre><code>        currentURL = currentURL.ToLower().Replace("http://", "");
  
          int idx1 = currentURL.IndexOf("/");
          int idx2 = currentURL.IndexOf("/", idx1);
  
          string secondlevelSite = currentURL.Substring(idx1, idx2 - idx1);
  </code></pre>