java--正则表达式使用

解析ip:

private String parseIp(String jdbc) {
        String pattern = "((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))";
        Pattern r = Pattern.compile(pattern);
        Matcher m = r.matcher(jdbc);
        if (m.find()) {
            return m.group();
        }
        return "";
    }
原文地址:https://www.cnblogs.com/jvStarBlog/p/11416088.html