Tales of a half pint...
:{1}\d*
Regex regex = new Regex( @":{1}\d{1,}" );string url = regex.Replace( "http://andrewgunn.blogspot.com:81/", string.Empty );
This code removes the colon from "http://" as well as the port.
This will do it:Regex regex = new Regex(@":{1}[0-9]{1}\d*"); string uriLeftPart = regex.Replace(Context.Request.Url.GetLeftPart(UriPartial.Authority), string.Empty); return uriLeftPart;
Thanks for spotting that. I've changed the post but I've gone for a slighlty different expression::{1}\d{1,}
Post a Comment
3 comments:
This code removes the colon from "http://" as well as the port.
This will do it:
Regex regex = new Regex(@":{1}[0-9]{1}\d*");
string uriLeftPart = regex.Replace(Context.Request.Url.GetLeftPart(UriPartial.Authority), string.Empty);
return uriLeftPart;
Thanks for spotting that. I've changed the post but I've gone for a slighlty different expression:
:{1}\d{1,}
Post a Comment