java表情处理

package com.xiaomi.deeplearning.chatbot.service;

public class SplitEmoji {

public static void main(String[] args) {

String input = "今天天气不错yeah ~_~ 😕";

//去表情ip2和ip3

String ip2 = input.replaceAll("[^\\u0000-\\uFFFF]", "");

String ip3 = input.replaceAll("[\\ud800\\udc00-\\udbff\\udfff\\ud800-\\udfff]", "");

//只保留表情

String ip4 = input.replaceAll("[^\\ud800\\udc00-\\udbff\\udfff\\ud800-\\udfff]", "");

System.out.println(input);

System.out.println(ip2);

System.out.println(ip3);

System.out.println(ip4);

}

}

/*result:

今天天气不错yeah ~_~ 😕

今天天气不错yeah ~_~

今天天气不错yeah ~_~

😕

*/

(0)

相关推荐