Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkuppe2008-05-30 08:22:17 -0400
committermkuppe2008-05-30 08:22:17 -0400
commite814be085bae2608142e7937245b71cf0639ad18 (patch)
tree597e33c283eceb6b3ef2c8bc511b60a54776b859 /framework/bundles/org.eclipse.ecf.identity/src
parent61e41996719e0e4a60a9002207a5bdbc97f65660 (diff)
downloadorg.eclipse.ecf-e814be085bae2608142e7937245b71cf0639ad18.tar.gz
org.eclipse.ecf-e814be085bae2608142e7937245b71cf0639ad18.tar.xz
org.eclipse.ecf-e814be085bae2608142e7937245b71cf0639ad18.zip
RESOLVED - bug 233807: Move replaceAllIgnoreCase to StringUtils
https://bugs.eclipse.org/bugs/show_bug.cgi?id=233807
Diffstat (limited to 'framework/bundles/org.eclipse.ecf.identity/src')
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/StringUtils.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/StringUtils.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/StringUtils.java
index 939c61d04..01c4bf6a3 100644
--- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/StringUtils.java
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/StringUtils.java
@@ -233,4 +233,24 @@ public final class StringUtils {
return string;
return string.substring(0, index) + replace + replaceAll(string.substring(index + target.length()), target, replace);
}
+
+ /**
+ * Returns the string resulting from replacing all occurrences of the target with the replace
+ * string. Note that the target matches literally but ignoring the case, and this is not the same behavior as the
+ * String.replaceAll, which uses regular expressions for doing the matching.
+ * @param string the start string. Must not be <code>null</code>.
+ * @param target the target to search for in the start string. Must not be <code>null</code>.
+ * @param replace the replacement string to substitute when the target is found. Must not be <code>null</code>.
+ * @return String result. Will not be <code>null</code>. If target is not found in the given string,
+ * then the result will be the entire input string.
+ *
+ * @see StringUtils#replaceAll(String, String, String) but case insensitive
+ */
+ public static String replaceAllIgnoreCase(String string, String target, String replace) {
+ final int index = string.toLowerCase().indexOf(target.toLowerCase());
+ if (index == -1)
+ return string;
+ return string.substring(0, index) + replace + replaceAllIgnoreCase(string.substring(index + target.length()), target, replace);
+ }
+
}

Back to the top