To find emojis in a string using regex in JavaScript, you can use the Unicode code points of emojis. An emoji can be represented by one or more Unicode code points, so you need to identify the code points for the emojis you want to match.
Here's an example regex pattern that matches common emojis:
index.tsx144 chars2 lines
This regex uses the Unicode code point ranges for the following emoji categories:
You can then use the .match()
method of a string to find all matches of emojis in the string:
index.tsx110 chars4 lines
Note that not all emojis may be included in this regex pattern, as new emojis are added to Unicode with each new version. You may need to update the regex pattern to include the code points for any new emojis you want to match.
gistlibby LogSnag