解决方案 »

  1.   

    就是判断,没有条件,输入一段字符串,if(=){str}else{null}就这样
      

  2.   

    jdk自带的正则表达式验证Pattern pattern = Pattern.compile(regex) // 参数是正则表达式Matcher matcher = pattern.matcher(input) // 参数是要匹配的字符串boolean b = matcher.matches(); 
      

  3.   

    谢谢
    Illegal repetition这个错误怎么处理?
      

  4.   

    谢谢
    Illegal repetition这个错误怎么处理?我不太擅长写正则表达式,只是知道怎么用,这个可能帮不到你了,你可以百度一下
      

  5.   

    谢谢
    Illegal repetition这个错误怎么处理?我不太擅长写正则表达式,只是知道怎么用,这个可能帮不到你了,你可以百度一下
    哦   好吧  谢谢
      

  6.   


        public static void main(String[] args) {
            // {"":"","":[],[]} 或者{"":{}}
            Pattern p1 = Pattern
                    .compile("(\\{\".*?\"\\:\".*?\",\"\".*?\\:\\[.*?\\],\\[.*?\\]\\})(\\{\".*?\"\\:\\{.*?\\}})");        String str = "sasasas";
            String test = "asasasascc{\"a\":{}}";
            String test2 = "asasasascc{\"\":{asdf}}";        Matcher m = p1.matcher(str);
            if (!m.find(1) && !m.find(2)) {
                str = null;
            }
            System.out.println(str);        Matcher m2 = p1.matcher(test);
            if (!m2.find(1) && m2.find(2)) {
                test = null;
            }
            System.out.println(test);
            
            Matcher m3 = p1.matcher(test2);
            if (!m3.find(1) && m3.find(2)) {
                test2 = null;
            }
            System.out.println(test2);
        }
    这个符合要求不