A regular expression to match all Emoji-only symbols as per the Unicode Standard.
Installations
npm install emoji-regex
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
18.20.4
NPM Version
10.7.0
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
Download Statistics
Total Downloads
17,305,152,972
Last Day
24,695,209
Last Week
114,135,268
Last Month
505,720,982
Last Year
5,733,963,867
GitHub Statistics
1,787 Stars
112 Commits
173 Forks
22 Watching
2 Branches
20 Contributors
Bundle Size
12.68 kB
Minified
2.26 kB
Minified + Gzipped
Package Meta Information
Latest Version
10.4.0
Package Id
emoji-regex@10.4.0
Unpacked Size
31.24 kB
Size
5.33 kB
File Count
6
NPM Version
10.7.0
Node Version
18.20.4
Publised On
26 Aug 2024
Total Downloads
Cumulative downloads
Total Downloads
17,305,152,972
Last day
-3.3%
24,695,209
Compared to previous day
Last week
-14.3%
114,135,268
Compared to previous week
Last month
5.7%
505,720,982
Compared to previous month
Last year
38%
5,733,963,867
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
3
emoji-regex
emoji-regex offers a regular expression to match all emoji symbols and sequences (including textual representations of emoji) as per the Unicode Standard. It’s based on emoji-test-regex-pattern, which generates (at build time) the regular expression pattern based on the Unicode Standard. As a result, emoji-regex can easily be updated whenever new emoji are added to Unicode.
Since each version of emoji-regex is tied to the latest Unicode version at the time of release, results are deterministic. This is important for use cases like image replacement, where you want to guarantee that an image asset is available for every possibly matched emoji. If you don’t need a deterministic regex, a lighter-weight, general emoji pattern is available via the emoji-regex-xs package that follows the same API.
Installation
Via npm:
1npm install emoji-regex
In Node.js:
1const emojiRegex = require('emoji-regex'); 2// Note: because the regular expression has the global flag set, this module 3// exports a function that returns the regex rather than exporting the regular 4// expression itself, to make it impossible to (accidentally) mutate the 5// original regular expression. 6 7const text = ` 8\u{231A}: ⌚ default emoji presentation character (Emoji_Presentation) 9\u{2194}\u{FE0F}: ↔️ default text presentation character rendered as emoji 10\u{1F469}: 👩 emoji modifier base (Emoji_Modifier_Base) 11\u{1F469}\u{1F3FF}: 👩🏿 emoji modifier base followed by a modifier 12`; 13 14const regex = emojiRegex(); 15for (const match of text.matchAll(regex)) { 16 const emoji = match[0]; 17 console.log(`Matched sequence ${ emoji } — code points: ${ [...emoji].length }`); 18}
Console output:
Matched sequence ⌚ — code points: 1
Matched sequence ⌚ — code points: 1
Matched sequence ↔️ — code points: 2
Matched sequence ↔️ — code points: 2
Matched sequence 👩 — code points: 1
Matched sequence 👩 — code points: 1
Matched sequence 👩🏿 — code points: 2
Matched sequence 👩🏿 — code points: 2
For maintainers
How to update emoji-regex after new Unicode Standard releases
-
Update emoji-test-regex-pattern as described in its repository.
-
Bump the emoji-test-regex-pattern dependency to the latest version.
-
Update the Unicode data dependency in
package.json
by running the following commands:1# Example: updating from Unicode v13 to Unicode v14. 2npm uninstall @unicode/unicode-13.0.0 3npm install @unicode/unicode-14.0.0 --save-dev
-
Generate the new output:
1npm run build
-
Verify that tests still pass:
1npm test
How to publish a new release
-
On the
main
branch, bump the emoji-regex version number inpackage.json
:1npm version patch -m 'Release v%s'
Instead of
patch
, useminor
ormajor
as needed.Note that this produces a Git commit + tag.
-
Push the release commit and tag:
1git push && git push --tags
Our CI then automatically publishes the new release to npm.
Author
Mathias Bynens |
License
emoji-regex is available under the MIT license.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE-MIT.txt:0
- Info: FSF or OSI recognized license: MIT License: LICENSE-MIT.txt:0
Reason
Found 5/30 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/mathiasbynens/emoji-regex/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish-on-tag.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/mathiasbynens/emoji-regex/publish-on-tag.yml/main?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/main.yml:19
- Warn: npmCommand not pinned by hash: .github/workflows/publish-on-tag.yml:16
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 npmCommand dependencies pinned
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/main.yml:1
- Warn: no topLevel permission defined: .github/workflows/publish-on-tag.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 5 are checked with a SAST tool
Score
3.5
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More