Android String Replace replace(String originalString, String searchString, String replaceString)

Here you can find the source of replace(String originalString, String searchString, String replaceString)

Description

replace

Declaration

public static String replace(String originalString,
            String searchString, String replaceString) 

Method Source Code

//package com.java2s;

public class Main {
    public static String replace(String originalString,
            String searchString, String replaceString) {
        StringBuilder sb = new StringBuilder(originalString);
        int index = sb.indexOf(searchString);
        while (index != -1) {
            sb.replace(index, index + searchString.length(), replaceString);
            index += replaceString.length();
            index = sb.indexOf(searchString, index);
        }/*w w w .  j av a  2 s.co  m*/
        return sb.toString();
    }
}

Related

  1. replace(String from, String to, String source)
  2. replace(String line, String oldString, String newString)
  3. replace(String str, Map replacementMap)
  4. replace(final String text, final String fromText, final String toText)
  5. replaceAll(String input, String searchStr, String replaceWithStr)
  6. replaceAllKanaWith(String text, String replacement)