All prefs administrated in external tools plugin.
[phpeclipse.git] / net.sourceforge.phpeclipse.externaltools / src / net / sourceforge / phpdt / externaltools / util / StringUtil.java
1 /*
2  * Created on 28.06.2003
3  *
4  */
5 package net.sourceforge.phpdt.externaltools.util;
6
7 /**
8  * some string utilities
9  *
10  */
11 public class StringUtil {
12
13   /**
14    * Replace each substring of str which matches findStr with replaceStr
15    *
16    * @param str        the string the substrings should be replaced in
17    * @param findStr    the substring to be replaced
18    * @param replaceStr the replacement
19    * @return the resultstring
20    */
21   public static final String replaceAll(String str, String findStr, String replaceStr) {
22     StringBuffer buf = new StringBuffer();
23
24     int lastindex = 0;
25     int indexOf = 0;
26     while ((indexOf=str.indexOf(findStr, lastindex)) != -1) {
27       buf.append(str.substring(lastindex, indexOf)).append(replaceStr);
28       lastindex = indexOf + findStr.length();
29     }
30     buf.append(str.substring(lastindex));
31     return buf.toString();
32   }
33   
34 }