62,163
社区成员
发帖
与我相关
我的任务
分享
<script language="javascript">
var re = /^(http:\/\/)?[^\/]*\//g;
var rv ;
rv = "http://localhost/Store.WebSiteUI/Suggest.aspx".match(re);
document.write(rv+"<br />");
rv = "www.test.com/testweb/default.aspx".match(re);
document.write(rv);
</script>
/// <summary>
/// 提取InternetURL的域名(Domain)
/// </summary>
/// <param name="input">对其匹配测试的字符串</param>
/// <returns>域名</returns>
public static string GetURLDomain(string input)
{
return Regex.Match(input, @"^(?<Domain>(http://)?[^/]+/?)", RegexOptions.IgnoreCase).Groups["Domain"].Value;
}
str=Regex.Match("www.test.com/testweb/default.aspx","^(http://)?[^/]*/");