PHP: How to match a range of unicode paired surrogates emoticons/emoji?

前端 未结 1 1180
天涯浪人
天涯浪人 2020-12-12 07:35

anubhava\'s answer about matching ranges of unicode characters led me to the regex to use for cleaning up a specific range of single code point of characters. With it, now I

相关标签:
1条回答
  • 2020-12-12 07:59

    revo's comment above was very helpful to find a solution:

    If your PHP isn't shipped with a PCRE build for UTF-16 then you can't perform such a match. From PHP 7.0 on, you're able to use Unicode code points following this syntax \u{XXXX} e.g. preg_replace("~\u{1F600}~", '', $str); (Mind the double quotes)

    Since I am using PHP 7, echo "\u{1F602}"; outputs

    0 讨论(0)
提交回复
热议问题