线上不修改mysql的存储引擎对emoji标签做删除处理(PHP)

记录一下 全部替换为"***",修改引擎代价有些大

function removeEmojiChar($str){
    $mbLen = mb_strlen($str);
    $strArr = array();
    for($i=0;$i<$mbLen;$i++){
        $mbSubstr = mb_substr($str, $i,1,'utf-8');
        $clean_text = "";
        // Match Emoticons
        $regexEmoticons = '/[\x{1F600}-\x{1F64F}]/u';
        $clean_text = preg_replace($regexEmoticons, '***', $mbSubstr);
        // Match Miscellaneous Symbols and Pictographs
        $regexSymbols = '/[\x{1F300}-\x{1F5FF}]/u';
        $clean_text = preg_replace($regexSymbols, '***', $clean_text);
        // Match Transport And Map Symbols
        $regexTransport = '/[\x{1F680}-\x{1F6FF}]/u';
        $clean_text = preg_replace($regexTransport, '***', $clean_text);
        // Match Miscellaneous Symbols
        $regexMisc = '/[\x{2600}-\x{26FF}]/u';
        $clean_text = preg_replace($regexMisc, '***', $clean_text);
        // Match Dingbats
        $regexDingbats = '/[\x{2700}-\x{27BF}]/u';
        $clean_text = preg_replace($regexDingbats, '***', $clean_text);
        $strArr[] = $clean_text;
    }
    
    return implode(' ', $strArr);
}

 

猜你喜欢

转载自www.cnblogs.com/xiaofan1949/p/10374495.html
0条评论
添加一条新回复