package com.reptileclient.jlifeapp.filter;

import org.springframework.stereotype.Service;

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

/**
 * @author fuxubing
 */
@Service
public class EmojiFilter implements Filter {

    @Override
    public String filter(String str) {
        if (str.trim().isEmpty()) {
            return str;
        }
        String pattern = "[\\ud800\\udc00-\\udbff\\udfff\\ud800-\\udfff]";
        String reStr = "";
        Pattern emoji = Pattern.compile(pattern);
        Matcher emojiMatcher = emoji.matcher(str);
        str = emojiMatcher.replaceAll(reStr);
        return str;
    }
}
