复制代码 代码如下:
public static String getHost(String url){
if(url==null||url.trim().equals("")){
return "";
}
String host = "";
Pattern p = Pattern.compile("(?<=//|)((\\w)+\\.)+\\w+");
Matcher matcher = p.matcher(url);
if(matcher.find()){
host = matcher.group();
}
return host;
}
时间: 2024-12-10 12:21:30