增加过滤字符串的方法

This commit is contained in:
lixiaohua
2020-08-01 21:09:40 +08:00
parent 02b0f6194f
commit 31b1902d6b
2 changed files with 35 additions and 14 deletions

View File

@@ -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);
}
}