var host = this.Request.Url.Host;
private string ExtractExtension(string host)
{
string result = null;
var pattern = @"[\w-]+\.[\w-]+(?<extension>(\.[\w-]+)+)";
var match = Regex.Match(host , pattern);
if (match.Groups["extension"].Success)
{
result = match.Groups["extension"].Value;
}
return result;
}
Note: this method is easily testable.
No comments:
Post a Comment