How do I use a pattern Url to extract a segment from an actual Url?
<p>If I have a series of "pattern" Urls of the form:</p>

<pre><code>http://{username}.sitename.com/
http://{username}.othersite.net/
http://mysite.com/{username}
</code></pre>

<p>and I have an actual Url of the form:</p>

<pre><code>http://joesmith.sitename.com/
</code></pre>

<p>Is there any way that I can match a pattern Url and in turn use it to extract the username portion out the actual Url? I've thought of nasty ways to do it, but it just seems like there should be a more intuitive way to accomplish this.</p>

<p>ASP.NET MVC uses a similar approach to extract the various segments of the URL when it is building its routes. Given the example:</p>

<pre><code>{controller}/{action}
</code></pre>

<p>So given the Url of the form, <code>Home/Index</code>, it knows that it is the Home controller calling the Index action method.</p>
