All prefs administrated in external tools plugin.
[phpeclipse.git] / net.sourceforge.phpeclipse.externaltools / src / net / sourceforge / phpdt / externaltools / util / StringUtil.java
diff --git a/net.sourceforge.phpeclipse.externaltools/src/net/sourceforge/phpdt/externaltools/util/StringUtil.java b/net.sourceforge.phpeclipse.externaltools/src/net/sourceforge/phpdt/externaltools/util/StringUtil.java
new file mode 100644 (file)
index 0000000..c5ef81d
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Created on 28.06.2003
+ *
+ */
+package net.sourceforge.phpdt.externaltools.util;
+
+/**
+ * some string utilities
+ *
+ */
+public class StringUtil {
+
+  /**
+   * Replace each substring of str which matches findStr with replaceStr
+   *
+   * @param str        the string the substrings should be replaced in
+   * @param findStr    the substring to be replaced
+   * @param replaceStr the replacement
+   * @return the resultstring
+   */
+  public static final String replaceAll(String str, String findStr, String replaceStr) {
+    StringBuffer buf = new StringBuffer();
+
+    int lastindex = 0;
+    int indexOf = 0;
+    while ((indexOf=str.indexOf(findStr, lastindex)) != -1) {
+      buf.append(str.substring(lastindex, indexOf)).append(replaceStr);
+      lastindex = indexOf + findStr.length();
+    }
+    buf.append(str.substring(lastindex));
+    return buf.toString();
+  }
+  
+}