产品经理这点事儿 潜水
  • 5发帖数
  • 5主题数
  • 0关注数
  • 0粉丝
开启左侧

PHP : 过滤emoji表情 writing a simple removeEmoji function

[复制链接]
使用 preg_replace 方法,是最简单的解决方案。
I read the wiki page and coded new regex since none of SO (or other websites) answers seemed to work for Instagram photo captions (API returning format) . Note: /u identifier is mandatory to match \x unicode chars.
public static function removeEmoji($text) {$clean_text = "";// Match Emoticons$regexEmoticons = '/[\x{1F600}-\x{1F64F}]/u';$clean_text = preg_replace($regexEmoticons, '', $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;}
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

猜你喜欢
在线客服邮箱
wxcy#wkgb.net

邮箱地址#换为@

Powered by 创意电子 ©2018-现在 专注资源实战分享源码下载站联盟商城