移除微信昵称中的emoji字符

移除微信昵称中的emoji字符:
/**
 * 移除微信昵称中的emoji字符
 * @param type $nickname
 * @return type
 */
function removeEmoji($nickname) {
    $clean_text = "";
    // Match Emoticons
    $regexEmoticons = '/[\x{1F600}-\x{1F64F}]/u';
    $clean_text = preg_replace($regexEmoticons, '', $nickname);
    // 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);
    //截取指定长度的昵称
    $clean_text = ds_substing($clean_text,0,20);
    return trim($clean_text);
}

 

上一篇:php正则表达式中preg_match_all函数的详解


下一篇:Bugku | 数字验证正则绕过