incenteev/emoji-pattern

PHP regexp pattern matching Unicode emojis

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

This package is auto-updated.

Last update: 2024-10-13 10:21:39 UTC


README

This package provides regexp patterns to match Unicode emojis. All forms of emojis are matched, including:

  • Single-character emoji (πŸ‘)
  • Emoji that are variants of other characters (e.g. ⌚️ instead of ⌚︎)
  • Fitzpatrick Modifiers (e.g. skintones πŸ‘πŸ»πŸ‘πŸΌπŸ‘πŸ½πŸ‘πŸΎπŸ‘πŸΏ)
  • ZWJ Sequences (e.g. πŸ’‘)
  • Combining sequences and Combining Marks (e.g. 0️⃣)
  • Flag sequences (e.g πŸ‡¨πŸ‡¦)

All emojis are derived directly from the standard unicode data files, using an automated script.

Total Downloads Latest Stable Version

Installation

Use Composer to install the library:

$ composer require incenteev/emoji-pattern

Usage

The provided pattern relies on the u modifier of PCRE and so works only for UTF-8 strings.

use Incenteev\EmojiPattern\EmojiPattern;

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

License

This package is under the MIT license.

Credits

The initial version of the package was a port of SwiftEmoji.

Reporting an issue or a feature request

Issues and feature requests are tracked in the Github issue tracker.