閱讀224 返回首頁    go 阿裏雲 go 技術社區[雲棲]


替換字符串中部分字符串,java

public  String replace(String from, String to, String source) 
     {   
        if (source == null || from == null || to == null)   
            return null;   
        StringBuffer bf = new StringBuffer("");   
        int index = -1;   
        while ((index = source.indexOf(from)) != -1) 
        {   
            bf.append(source.substring(0, index) + to);   
            source = source.substring(index + from.length());   
            index = source.indexOf(from);   
        }   
        bf.append(source);   
        return bf.toString();   
    }


https://slddyb.blog.51cto.com/2294765/409676

最後更新:2017-04-02 16:47:54

  上一篇:go log4j的日誌級別
  下一篇:go 自定義ContentProvider 實例演示