incenteev/emoji-pattern

PHP正则表达式匹配Unicode表情符号

v1.4.0 2024-09-13 10:13 UTC

This package is auto-updated.

Last update: 2024-09-13 10:14:15 UTC


README

此包提供用于匹配Unicode表情符号的正则表达式模式。所有形式的表情符号都可以匹配,包括

  • 单字符表情符号(👍)
  • 其他字符的变体表情符号(例如,⌚️而不是⌚︎)
  • Fitzpatrick修饰符(例如,肤色调👍🏻👍🏼👍🏽👍🏾👍🏿)
  • ZWJ序列(例如,💑)
  • 组合序列和组合标记(例如,0️⃣)
  • 国旗序列(例如 🇨🇦)

所有表情符号都直接来自标准的Unicode数据文件,使用自动化脚本。

Total Downloads Latest Stable Version

安装

使用Composer安装库

$ composer require incenteev/emoji-pattern

用法

提供的模式依赖于PCRE的u修饰符,因此仅适用于UTF-8字符串。

use Incenteev\EmojiPattern\EmojiPattern;

$emojiRegexp = '/' . EmojiPattern::getEmojiPattern() . '/u';

许可证

此包受MIT许可证的约束。

鸣谢

此包的初始版本是从SwiftEmoji移植的。

报告问题或功能请求

问题和功能请求在Github问题跟踪器中跟踪。