Match Emojis with Regular Expressions
When experimenting with unicode property escapes, to identify accented letters in strings, it reminded me of a question I had a few years ago: what is the best way to identify and then replace emojis in a string? I first noticed this practice when using emojis in Facebook -- sometimes Facebook would replace an emoji with one of their own custom images, likely because another device may not support that emoji.
Much the way you can match accented characters, you can use unicode property escapes to match emojis:
const emojis = "😂😂💯".match(/\p{Emoji_Presentation}/gu);
// ["😂", "😂", "💯"]
I've previously seen massive arrays of every emoji ever created, and it may be possible that {Emoji_Presentation}
doesn't contain all emojis across all devices, but this regex has matched every case I've come across.
Happy emoji....ing!
One of my favorite social APIs was the Open Graph API adopted by Facebook. Adding just a few META tags to each page allowed links to my article to be styled and presented the way I wanted them to, giving me a bit of control...
Chances are that any Web designers using our Ghostlab browser testing app, which allows seamless testing across all devices simultaneously, will have worked with responsive design in some shape or form. And as today's websites and devices become ever more varied, a plethora of responsive images...
One of the most used JavaScript widgets over the past decade has been the text box autocomplete widget. Every JavaScript framework has their own autocomplete widget and many of them have become quite advanced. Much like the placeholder attribute's introduction to markup, a frequently used...
A few of my customer have asked for me to create a subtle but dynamic (...I know...) way for them to advertise different specials on their website. Not something that would display on every page, but periodically or only the homepage. Using a trick...
Great stuff!
But actually there are quite a few where
Emoji_Presentation
does not work. Probably most of (all?) marked here as not Emoji_Presentation https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt but Extended_Pictographic or just Emoji.work too well (matching 1-9, # and *) but
seems to do the charm :)