How can I identify an emoji in scala?
emoji, regex, scala, string, twitter
Solution
You can use the following Regex to find emoji characters (and other characters outside the Unicode lingual plane):
`[^\u0000-\uFFFF]`
For example, we use the following code to filter out emojis from strings:
`"some string".replaceAll("[^\u0000-\uFFFF]", "");`
Hope that helps.
Problem
I am processing tweets from the Twitter Api, and a lot of the tweets have emojis. I'm trying to keep track of the most used emojis, but I'm having trouble actually identifying them. I'm using: https://github.com/iamcal/emoji-data to identify emojis. I have no idea how to figure out if a string contains an emoji or not. I have tried using regex with the emoji-data 'unified' field, I have tried just checking if the string contains that field. I'm really just not sure how to check for emojis.. Any help would be appreciated. ``` val pattern = new Regex("(${a.unified})") (pattern findAllIn text).mkString(",") ``` This is what I have tried using regex. This doesn't find any emojis. I have also tried adding a \u before the unified fields from the emoji-data, but that doesn't help.