Merge pull request #2533 from Herm2s/v5-dev

feature: StrUtil增加替换字符串中第一个指定字符串和最后一个指定字符串方法
This commit is contained in:
Golden Looly
2022-08-20 01:13:14 +08:00
committed by GitHub
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");
}
}