replace string use another

时间:2017-12-02 10:42:42   收藏:0   阅读:237
String s = "abcdabc";
        String tt = "bc";
        String ttt = "e";
        int index = 0;
        while (s.indexOf("bc", index) != -1) {
            index = s.indexOf("bc", index);
            s = s.substring(0, index) + ttt + s.substring(index + tt.length());
        }
        System.out.println(s);

  

原文:http://www.cnblogs.com/apanda009/p/7952874.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!