Created
March 20, 2024 02:51
-
-
Save johnrcui/6b073ef95cffc11befacc541ffa66283 to your computer and use it in GitHub Desktop.
Detect and strip emojis from text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const RE_EMOJI = /[\p{So}\p{Sk}\p{S}\p{M}]/gu; | |
| export const isEmoji = (str: string) => RegExp('^' + RE_EMOJI.source + '$', 'gu').test(str); | |
| export const stripEmoji = (str: string) => str.replace(RE_EMOJI, ''); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment