SwiftEmoji
provides a set of regular expressions to find emoji in swift strings. All forms of emoji 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 emoji are derived directly from the standard unicode data files, using an automated script.
The Emoji
class exposes a number of useful regular expressions as static variables. They each come
in compiled (NSRegularExpression
) and uncompiled (String
) forms.
SingleEmojiPattern
andSingleEmojiRegex
match a single emoji character (grapheme cluster).MultiEmojiPattern
andMultiEmojiRegex
match one or more consecutive emoji characters.
The String
values are useful when composing your own expressions. For example, you could
Look at the source code in Emoji.swift
for an example.
SwiftEmoji
can be installed via CocoaPods, Carthage, or Swift Package Manager.
SwiftEmoji is released under the MIT License. Details are in the LICENSE.txt
file in the project.