java 过滤表情符号

/**
* 过滤表情符号
* @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;
}
posted @ 2016-10-25 14:05  #料  阅读(3785)  评论(0编辑  收藏  举报