码迷,mamicode.com
首页 > 其他好文 > 详细

处理重复问题

时间:2016-01-13 21:51:20      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:

1.

public static void main(String args[])
    {
        String[] arr={"12345678","12342311987","abababab"};
        for(String str:arr){
            boolean flag=false;
            String matcherStr="";
            for(int i=0;i<str.length();i++){
                for(int j=i+1;j<str.length();j++){
                    String temp=str.substring(i,j);
                    temp=temp+temp;
                    Matcher m=Pattern.compile(temp).matcher(str);
                    if(m.find()){
                        matcherStr=temp;
                        flag=true;
                        break;
                    }
                }
               
            }
            if(flag){
                System.out.println(str+":check->false,multiplicity string:"+matcherStr);  
            }else{
                System.out.println(str+":check->true");  
                flag=false;
            }
        }
    }

2.

    if(str.matches("^.*?(.+?)\\1.*?$")){
      System.out.println("有重复");
    }

 

处理重复问题

标签:

原文地址:http://www.cnblogs.com/zhujiabin/p/5128353.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!