Fix SourceLookupMessage constant.(SourceLookupMessages.DefaultSourceContainer_0 eclip...
[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
17          *            the string the substrings should be replaced in
18          * @param findStr
19          *            the substring to be replaced
20          * @param replaceStr
21          *            the replacement
22          * @return the resultstring
23          */
24         public static final String replaceAll(String str, String findStr,
25                         String replaceStr) {
26                 StringBuffer buf = new StringBuffer();
27
28                 int lastindex = 0;
29                 int indexOf = 0;
30                 while ((indexOf = str.indexOf(findStr, lastindex)) != -1) {
31                         buf.append(str.substring(lastindex, indexOf)).append(replaceStr);
32                         lastindex = indexOf + findStr.length();
33                 }
34                 buf.append(str.substring(lastindex));
35                 return buf.toString();
36         }
37
38 }