//判断是否包含表情
public static boolean findEmoji(String content) {
Pattern pattern = Pattern.compile("[^\u0000-\uFFFF]");
Matcher matcher = pattern.matcher(content);
return matcher.find();
}
private static boolean isEmojiCharacter(char codePoint) {
return (codePoint == 0x0) ||
(codePoint == 0x9) ||
(codePoint == 0xA) ||
(codePoint == 0xD) ||
((codePoint >= 0x20) && (codePoint <= 0xD7FF)) ||
((codePoint >= 0xE000) && (codePoint <= 0xFFFD)) ||
((codePoint >= 0x10000) && (codePoint <= 0x10FFFF));
}
//进行替换
public static String filterEmoji(String source) {
source = source.replaceAll("[\ud800\udc00-\udbff\udfff\ud800-\udfff]", “*”);
if (!findEmoji(source)) {
return source;//如果不包含ÿ