1-65535

public class Test {
    public static void main(String[] args) {
        String regexPort = "^((6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|6[0-4][0-9]{3}|[1-5][0-9]{4}|[1-9][0-9]{0,3}))|"
                + "((6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|6[0-4][0-9]{3}|[1-5][0-9]{4}|[1-9][0-9]{0,3})[,])*"
                + "(((6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|6[0-4][0-9]{3}|[1-5][0-9]{4}|[1-9][0-9]{0,3})){1})$";
        String cgiPort = "65535,,,,333";
            if(!cgiPort.matches(regexPort)){
            System.out.println("false");
            }else{
                System.out.println("true");
            }
    }
    
}

思想:

http://www.zjmainstay.cn/deep-regexp

http://www.cnblogs.com/yrcumt2010/archive/2011/01/13/1934601.html

posted @ 2016-07-18 17:14  纯粹的人  阅读(314)  评论(0编辑  收藏  举报