Skip to content

Instantly share code, notes, and snippets.

@censuradho
Created June 22, 2023 13:59
Show Gist options
  • Save censuradho/fdb272e1448a5adbd9559d79ff222f7d to your computer and use it in GitHub Desktop.
Save censuradho/fdb272e1448a5adbd9559d79ff222f7d to your computer and use it in GitHub Desktop.
function to only accept emojis, pass a string as the first parameter and it returns an array of found emojis
/**
* getEmojisFromString('This 😃 is an Emoji exemple ❤️') // ['😃', '❤️']
*/
function getEmojisFromString (str: string) {
return str.match(/\p{Emoji}+/gu)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment