diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java index d83f28bd3..a76e3f2cd 100644 --- a/src/main/java/org/apache/commons/lang3/StringUtils.java +++ b/src/main/java/org/apache/commons/lang3/StringUtils.java @@ -4867,6 +4867,7 @@ public class StringUtils { * StringUtils.replaceAll("", "", "zzz") = "zzz" * StringUtils.replaceAll("", ".*", "zzz") = "zzz" * StringUtils.replaceAll("", ".+", "zzz") = "" + * StringUtils.replaceAll("abc", "", "ZZ") = "ZZaZZbZZcZZ" * StringUtils.replaceAll("<__>\n<__>", "<.*>", "z") = "z\nz" * StringUtils.replaceAll("<__>\n<__>", "(?s)<.*>", "z") = "z" * StringUtils.replaceAll("ABCabc123", "[a-z]", "_") = "ABC___123" @@ -4920,6 +4921,7 @@ public class StringUtils { * StringUtils.replaceFirst("", "", "zzz") = "zzz" * StringUtils.replaceFirst("", ".*", "zzz") = "zzz" * StringUtils.replaceFirst("", ".+", "zzz") = "" + * StringUtils.replaceFirst("abc", "", "ZZ") = "ZZabc" * StringUtils.replaceFirst("<__>\n<__>", "<.*>", "z") = "z\n<__>" * StringUtils.replaceFirst("<__>\n<__>", "(?s)<.*>", "z") = "z" * StringUtils.replaceFirst("ABCabc123", "[a-z]", "_") = "ABC_bc123" diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java index 2a4b41549..d6fc7ae68 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java @@ -1226,7 +1226,7 @@ public class StringUtilsTest { } @Test - public void testReplaceAll_StringStringString() { + public void testReplaceAll() { assertNull(StringUtils.replaceAll(null, "", "")); assertEquals("any", StringUtils.replaceAll("any", null, "")); @@ -1235,6 +1235,7 @@ public class StringUtilsTest { assertEquals("zzz", StringUtils.replaceAll("", "", "zzz")); assertEquals("zzz", StringUtils.replaceAll("", ".*", "zzz")); assertEquals("", StringUtils.replaceAll("", ".+", "zzz")); + assertEquals("ZZaZZbZZcZZ", StringUtils.replaceAll("abc", "", "ZZ")); assertEquals("z\nz", StringUtils.replaceAll("<__>\n<__>", "<.*>", "z")); assertEquals("z", StringUtils.replaceAll("<__>\n<__>", "(?s)<.*>", "z")); @@ -1254,7 +1255,7 @@ public class StringUtilsTest { } @Test - public void testReplaceFirst_StringStringString() { + public void testReplaceFirst() { assertNull(StringUtils.replaceFirst(null, "", "")); assertEquals("any", StringUtils.replaceFirst("any", null, "")); @@ -1263,6 +1264,7 @@ public class StringUtilsTest { assertEquals("zzz", StringUtils.replaceFirst("", "", "zzz")); assertEquals("zzz", StringUtils.replaceFirst("", ".*", "zzz")); assertEquals("", StringUtils.replaceFirst("", ".+", "zzz")); + assertEquals("ZZabc", StringUtils.replaceFirst("abc", "", "ZZ")); assertEquals("z\n<__>", StringUtils.replaceFirst("<__>\n<__>", "<.*>", "z")); assertEquals("z", StringUtils.replaceFirst("<__>\n<__>", "(?s)<.*>", "z"));