敏感词工具类SensitiveUtil支持自定义字符过滤规则

This commit is contained in:
neko 2020-09-26 23:47:31 +08:00 committed by GitHub
parent 870ea9a329
commit f1ea1da90f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,12 +73,15 @@ public final class SensitiveUtil {
} }
/** /**
* 是否包含敏感词 * 设置字符过滤规则通过定义字符串过滤规则过滤不需要的字符<br>
* @param text 文本 * 当accept为false时此字符不参与匹配
* @return 是否包含 *
* @param charFilter 过滤函数
*/ */
public static boolean containsSensitive(String text){ public static void setCharFilter(Filter<Character> charFilter) {
return sensitiveTree.isMatch(text); if(charFilter != null) {
sensitiveTree.setCharFilter(charFilter);
}
} }
/** /**