mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-08-18 20:38:02 +08:00
Merge pull request #2533 from Herm2s/v5-dev
feature: StrUtil增加替换字符串中第一个指定字符串和最后一个指定字符串方法
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user