Closed venusdrogon closed 5 years ago
@Test
public void testSelectPredicateTest(){
String string = "15002841618";
String regexPattern = "^1[3456789]\\d{9}$";
//---------------------------------------------------------------
List<String> list = toList(//
null,
string,
string,
string,
null,
string,
"飞龙",
"",
"jinxin",
string,
string);
List<String> select = select(list, new RegexStringPredicate(regexPattern));
assertThat(
select,
allOf(//
hasItem(string),
not(hasItem("飞龙")),
not(hasItem("")),
not(hasItem((String) null)),
not(hasItem("jinxin"))
//
));
}
适用于在 字符串 list 中查找 特定格式的字符串
新建 RegexStringPredicate