C#正则表达式获取网址的域名(IP)
时间:2015-04-21 09:30:47
收藏:0
阅读:426
代码如下:
string p = @"(http|https)://(?<domain>[^(:|/]*)"; Regex reg = new Regex(p, RegexOptions.IgnoreCase); Match m = reg.Match(HostUrl); Result=m.Groups["domain"].Value;
如http://localhost:8733/HVMsg/HVWcfService/获取的是:localhost
如http://guonei.news.baidu.com/n?cmd=1&class=shizheng获取的是:guonei.news.baidu.com
原文:http://www.cnblogs.com/rabtor/p/4443374.html
评论(0)