格式为 XXX.XXX.XXX.XXX+空格+端口号 给出示例代码即可,谢谢!

解决方案 »

  1.   

    Pattern p = Pattern.compile("(\\d{1,3}\\.){3}\\d{1,3} \\d{1,5}");
    Matcher m = p.matcher("127.0.0.1 8080");
    System.out.println( m.find());
      

  2.   

    String str ="[1-9]*\\.[0-9]*\\.[0-9]*\\.[0-9]*"//ip首个字节必须大于0,当然这里就不判断是否在256以内了
    Pattern p =Pattern.compile(str);
    Macher m=p.match("127.0.0.1");
    System.out.println("如果是符合条件的ip返回TRUE:"+p.matches())