zoukankan      html  css  js  c++  java
  • 去除字符串中的emoji表情

    以下为php版示例代码:

    public function removeEmoji($clean_text)
    {
        // 方法1:只取合法字符
        preg_match_all("/[x{4e00}-x{9fa5}|0-9|a-z|A-Z|_]/u", $clean_text, $matches);
        $clean_text = isset($matches[0]) ? implode('', $matches[0]) : '';
    
    
        // 方法2:去除表情字符,但测试过程中发现无法出去“国旗”表情
        // Match Emoticons
        $regexEmoticons = '/[x{1F600}-x{1F64F}]/u';
        $clean_text = preg_replace($regexEmoticons, '', $clean_text);
    
        // 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);
    
        return $clean_text;
    }
    
  • 相关阅读:
    IOS照相
    起学习iOS开发专用词汇
    django[post与get测试]
    起名字好难啊!(初识Django)
    MTV模型
    Django安装以及介绍
    数据库操作
    数据库其它操作
    数据库经典习题,
    数据库基本操作
  • 原文地址:https://www.cnblogs.com/chenguoli/p/7607277.html
Copyright © 2011-2022 走看看