package com.hotent.uc.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ToolUtil {

    public static String removeEmo(String text){
        Pattern emojiPattern = Pattern.compile("[\\ud800-\\udbff][\\udc00-\\udfff]|[\\u2600-\\u27FF]", Pattern.UNICODE_CHARACTER_CLASS);
        Matcher matcher = emojiPattern.matcher(text);

        while (matcher.find()) {
            int startIndex = matcher.start();
            int endIndex = matcher.end();

            System.out.println("Found an emoji at index [" + startIndex + ", " + endIndex + ")");

            StringBuilder sb = new StringBuilder(text);
            sb.delete(startIndex, endIndex);
            text = sb.toString();

            matcher = emojiPattern.matcher(text);
        }
        return text;
    }
}
