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; }