A one line function to replace characters in a C# string
<p>I have strings like:</p>

<pre><code>http://127.0.0.1:22/Test
</code></pre>

<p>Is there some single function maybe using regular expressions that I can use to make remove the colon and port number. </p>

<p>It was previously suggested that I use the following but this is giving me problems if the CurrentUrl is null!</p>

<pre><code>var ip = new Uri((string)Session["CurrentUrl"]);
var ipNoPort = string.Format("{0}://{1}/{2}", ip.Scheme, ip.Host, ip.PathAndQuery);
return Session["CurrentUrl"] == null ? Home() : Redirect((string)ipNoPort);
</code></pre>

<p>What I really need is some method that combines the three lines and checks for null also.</p>
