Java String Substritute substituteSymbol(String text, String symbol, String value)

Here you can find the source of substituteSymbol(String text, String symbol, String value)

Description

String substitution routine.

License

LGPL

Parameter

Parameter Description
text the initial text.
symbol the string to be substituted.
value the string that the "symbol" will be substituted with, in the "text" (all occurences).

Return

the changed text.

Declaration

public static String substituteSymbol(String text, String symbol, String value) 

Method Source Code

//package com.java2s;
//   jSMSEngine is distributed under the LGPL license.

public class Main {
    /**/*from ww  w . j  a v  a  2s . c o  m*/
       String substitution routine.
        
       @param   text   the initial text.
       @param   symbol   the string to be substituted.
       @param   value   the string that the "symbol" will be substituted with, in the "text" (all occurences).
        
       @return   the changed text.
    */
    public static String substituteSymbol(String text, String symbol, String value) {
        StringBuffer buffer;

        while (text.indexOf(symbol) >= 0) {
            buffer = new StringBuffer(text);
            buffer.replace(text.indexOf(symbol), text.indexOf(symbol) + symbol.length(), value);
            text = buffer.toString();
        }
        return text;
    }
}

Related

  1. substitutePropertyWithIn(String propertyName, String replacementString, String evaluatedString)
  2. substituteSelectedCharacters(String text, boolean skip)
  3. substituteSpaces(String originalPath)
  4. substituteSubString(String input, String find, String replace)
  5. substituteSymbol(String text, String symbol, String value)
  6. substituteTabsAndNewLinesWithSpaces(String str)
  7. substituteText(String text, String token, String substitute)
  8. substituteToken(StringBuffer buf, String token, String value)
  9. substituteUserId(final long aUserId, final String aTemplate)