示例:长链接:https://www.baidu.com?a=1&b=2
域名:www.baidu.com
static String getDomainUrl(String url) {
String domainUrl = "";
Pattern p = Pattern.compile("(?<=//|)((\w)+\.)+\w+");
Matcher m = p.matcher(url);
if (m.find()) {
domainUrl = m.group();
}
return domainUrl;
}