mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
敏感词工具类SensitiveUtil支持自定义字符过滤规则
This commit is contained in:
parent
870ea9a329
commit
f1ea1da90f
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user