判断ip是否合法

来源:互联网 发布:淘宝号几单有一心 编辑:程序博客网 时间:2024/06/11 11:50
    //用来判断ip是否合法
    public boolean checkIp(String tempIp) {        String regex = "(25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]?\\d)){3}";        Pattern p = Pattern.compile(regex);        Matcher m = p.matcher(tempIp);        return m.matches();    }


0 0