我认为preg_replace函数是最简单的解决方案。
正如EaterOfCode所建议的那样,由于没有SO(或其他网站)答案似乎适用于Instagram照片标题(API返回格式),因此我阅读了Wiki页并为新的正则表达式编码。注意:/u标识符必须匹配 x unipre字符。
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;}该功能不会删除所有表情符号,因为还有更多表情符号,但是您明白了。



