mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
增加过滤字符串的方法
This commit is contained in:
@@ -456,4 +456,12 @@ public class StrUtilTest {
|
||||
String brief = StrUtil.brief(str, maxLength);
|
||||
Assert.assertEquals(brief.length(), maxLength);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterTest() {
|
||||
final String filterNumber = StrUtil.filter("hutool678", CharUtil::isNumber);
|
||||
Assert.assertEquals(filterNumber, "678");
|
||||
String cleanBlank = StrUtil.filter(" 你 好 ", c -> !CharUtil.isBlankChar(c));
|
||||
Assert.assertEquals("你好", cleanBlank);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user