Skip to content

Instantly share code, notes, and snippets.

@johnrcui
Created March 20, 2024 02:51
Show Gist options
  • Select an option

  • Save johnrcui/6b073ef95cffc11befacc541ffa66283 to your computer and use it in GitHub Desktop.

Select an option

Save johnrcui/6b073ef95cffc11befacc541ffa66283 to your computer and use it in GitHub Desktop.
Detect and strip emojis from text
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