Connection conn = C3P0Util.getInstance().getConnection(C3P0Util.SOURCE); String url = conn.getMetaData().getURL(); String host = ""; Pattern p = Pattern.compile("(?<=//|)((\\w)+\\.)+\\w+"); Matcher matcher = p.matcher(url); if (matcher.find()) { host = matcher.group(); } System.out.println(host);原文链接:https://www.f2er.com/regex/361028.html