public static void main(String[] args) {
String aimStr = "jdbc:hive2://176.16.2.125:10000/ods_hive_test";
Pattern pattern = Pattern.compile("(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)");
Matcher m = pattern.matcher(aimStr);
if(m.find()) {
System.out.println(m.group());
}
}
//如果要判断带冒号的话:
//pattern里的正则最后加上个冒号就好了
Pattern pattern = Pattern.compile("(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?):");