【发布时间】:2019-01-11 15:35:53
【问题描述】:
我想创建坏词过滤器。这是我的示例代码:
String name = "jack white"; // **NOT WORK**
String name = "white"; // **WORK**
String lowername = name.toLowerCase();
String[] banned = { "name", "hello", "white"};
if (Arrays.asList(banned).contains(lowername)) {
true;
}
如果 name white 功能有效,但 name jack white、xxx white 或 white xxx 功能无效。
我想为用户cmets做一个坏词过滤器。
【问题讨论】:
-
你能不能更详细地说明你想要什么。
-
包含比较整个条目而不是部分
-
这看起来像是一个复杂的问题。
-
我建议查看模式和模式匹配器以及正则表达式。这些会有所帮助。
-
@chrylis:是的,当然。 thedailywtf.com/articles/The-Clbuttic-Mistake-
标签: java android arrays string filter