incenteev / emoji-pattern
PHP regexp pattern matching Unicode emojis
Installs: 264 197
Dependents: 2
Suggesters: 0
Security: 0
Stars: 10
Watchers: 5
Forks: 1
Open Issues: 0
Requires
- php: >=7.4
Requires (Dev)
- ext-mbstring: *
- phpstan/phpstan: ^1.10.39
- phpstan/phpstan-deprecation-rules: ^1.1.4
- phpstan/phpstan-phpunit: ^1.3.15
- phpunit/phpunit: ^9.6.13
- symfony/http-client: ^5.4.29 || ^6.3.5
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.
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.