regexemojionigurumaemoji-tones

Regular expression for capturing all skin-tone variations of an emoji


I'm trying to use a regex to capture tweets containing the substring πŸ‘ at least twice, so I'm using an unsophisticated ^.+ πŸ‘ .+ πŸ‘ .+$. However this doesn't match strings which instead contain, for example, πŸ‘πŸΌ.

Is there a smart way I can capture an emoji with any or none skin-tone variation, without just putting each one in a row (like [πŸ‘πŸ‘πŸ»πŸ‘πŸΌπŸ‘πŸ½πŸ‘πŸΎπŸ‘πŸΏ])?


Solution

  • Thanks to comments above, I've found that emojis I've encountered on twitter are unicode, and skin-tone variations are combining characters in the range 1f3fb–1f3ff.

    http://unicode.org/reports/tr51/#Emoji_Modifiers_Table

    So for me what I wanted was πŸ‘[\x{1f3fb}-\x{1f3ff}]?, with [\x{1f3fb}-\x{1f3ff}]? being something I can then drop next to any unmodified emoji to include skin-tone variations.