/**
* 过滤表情符号
* @create by ldw on 2016-10-25
* @param str
* @return str(去掉表情符号的字符串)
* @version 1.0
* */
public String filter(String str) {
if (str.trim().isEmpty()) {
return str;
}
String pattern = "[\ud83c\udc00-\ud83c\udfff]|[\ud83d\udc00-\ud83d\udfff]|[\u2600-\u27ff]";
String reStr = "";
Pattern emoji = Pattern.compile(pattern);
Matcher emojiMatcher = emoji.matcher(str);
str = emojiMatcher.replaceAll(reStr);
return str;
}
//亲自试过,管用
网友评论