java udp地址匹配

public static boolean regexUdpUrl(String url)
    {
        if (url == null)
            return false;
        Pattern pattern = Pattern
                .compile("[udp]+[://]+((\d){1,})+\.((\d){1,})+\.((\d){1,})+\.((\d){1,})+:((\d){1,})");
        
        Matcher matcher = pattern.matcher(url);

        if(matcher.matches())
        {
      
            return Integer.valueOf(matcher.group(1))< 255
                    &&Integer.valueOf(matcher.group(3))<255
                    &&Integer.valueOf(matcher.group(5))<255
                    &&Integer.valueOf(matcher.group(7))<255
                    &&Integer.valueOf(matcher.group(9))<65536;

        }
        else
        {
            return false;
        }

    }

原文地址:https://www.cnblogs.com/rspb/p/4618481.html