feature: StrUtil增加替换字符串中第一个指定字符串和最后一个指定字符串方法

This commit is contained in:
herm2s
2022-08-15 17:50:11 +08:00
parent 2f66008d02
commit d6aa8fdb96
2 changed files with 76 additions and 0 deletions

View File

@@ -618,5 +618,17 @@ public class StrUtilTest {
Assert.assertTrue(StrUtil.containsAll(a, "214", "234"));
}
@Test
public void replaceLastTest() {
String str = "i am jackjack";
String result = StrUtil.replaceLast(str, "JACK", null, true);
Assert.assertEquals(result, "i am jack");
}
@Test
public void replaceFirstTest() {
String str = "yesyes i do";
String result = StrUtil.replaceFirst(str, "YES", "", true);
Assert.assertEquals(result, "yes i do");
}
}