source: frontend/node_modules/emoji-regex/README.md

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 2 weeks ago

Fix frontend appearance

  • Property mode set to 100644
File size: 4.4 KB
Line 
1# emoji-regex [![Build status](https://travis-ci.org/mathiasbynens/emoji-regex.svg?branch=main)](https://travis-ci.org/mathiasbynens/emoji-regex)
2
3_emoji-regex_ offers a regular expression to match all emoji symbols and sequences (including textual representations of emoji) as per the Unicode Standard.
4
5This repository contains a script that generates this regular expression based on [Unicode data](https://github.com/node-unicode/node-unicode-data). Because of this, the regular expression can easily be updated whenever new emoji are added to the Unicode standard.
6
7## Installation
8
9Via [npm](https://www.npmjs.com/):
10
11```bash
12npm install emoji-regex
13```
14
15In [Node.js](https://nodejs.org/):
16
17```js
18const emojiRegex = require('emoji-regex/RGI_Emoji.js');
19// Note: because the regular expression has the global flag set, this module
20// exports a function that returns the regex rather than exporting the regular
21// expression itself, to make it impossible to (accidentally) mutate the
22// original regular expression.
23
24const text = `
25\u{231A}: ⌚ default emoji presentation character (Emoji_Presentation)
26\u{2194}\u{FE0F}: ↔️ default text presentation character rendered as emoji
27\u{1F469}: 👩 emoji modifier base (Emoji_Modifier_Base)
28\u{1F469}\u{1F3FF}: 👩🏿 emoji modifier base followed by a modifier
29`;
30
31const regex = emojiRegex();
32let match;
33while (match = regex.exec(text)) {
34 const emoji = match[0];
35 console.log(`Matched sequence ${ emoji } — code points: ${ [...emoji].length }`);
36}
37```
38
39Console output:
40
41```
42Matched sequence ⌚ — code points: 1
43Matched sequence ⌚ — code points: 1
44Matched sequence ↔️ — code points: 2
45Matched sequence ↔️ — code points: 2
46Matched sequence 👩 — code points: 1
47Matched sequence 👩 — code points: 1
48Matched sequence 👩🏿 — code points: 2
49Matched sequence 👩🏿 — code points: 2
50```
51
52## Regular expression flavors
53
54The package comes with three distinct regular expressions:
55
56```js
57// This is the recommended regular expression to use. It matches all
58// emoji recommended for general interchange, as defined via the
59// `RGI_Emoji` property in the Unicode Standard.
60// https://unicode.org/reports/tr51/#def_rgi_set
61// When in doubt, use this!
62const emojiRegexRGI = require('emoji-regex/RGI_Emoji.js');
63
64// This is the old regular expression, prior to `RGI_Emoji` being
65// standardized. In addition to all `RGI_Emoji` sequences, it matches
66// some emoji you probably don’t want to match (such as emoji component
67// symbols that are not meant to be used separately).
68const emojiRegex = require('emoji-regex/index.js');
69
70// This regular expression matches even more emoji than the previous
71// one, including emoji that render as text instead of icons (i.e.
72// emoji that are not `Emoji_Presentation` symbols and that aren’t
73// forced to render as emoji by a variation selector).
74const emojiRegexText = require('emoji-regex/text.js');
75```
76
77Additionally, in environments which support ES2015 Unicode escapes, you may `require` ES2015-style versions of the regexes:
78
79```js
80const emojiRegexRGI = require('emoji-regex/es2015/RGI_Emoji.js');
81const emojiRegex = require('emoji-regex/es2015/index.js');
82const emojiRegexText = require('emoji-regex/es2015/text.js');
83```
84
85## For maintainers
86
87### How to update emoji-regex after new Unicode Standard releases
88
891. Update the Unicode data dependency in `package.json` by running the following commands:
90
91 ```sh
92 # Example: updating from Unicode v12 to Unicode v13.
93 npm uninstall @unicode/unicode-12.0.0
94 npm install @unicode/unicode-13.0.0 --save-dev
95 ````
96
971. Generate the new output:
98
99 ```sh
100 npm run build
101 ```
102
1031. Verify that tests still pass:
104
105 ```sh
106 npm test
107 ```
108
1091. Send a pull request with the changes, and get it reviewed & merged.
110
1111. On the `main` branch, bump the emoji-regex version number in `package.json`:
112
113 ```sh
114 npm version patch -m 'Release v%s'
115 ```
116
117 Instead of `patch`, use `minor` or `major` [as needed](https://semver.org/).
118
119 Note that this produces a Git commit + tag.
120
1211. Push the release commit and tag:
122
123 ```sh
124 git push
125 ```
126
127 Our CI then automatically publishes the new release to npm.
128
129## Author
130
131| [![twitter/mathias](https://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") |
132|---|
133| [Mathias Bynens](https://mathiasbynens.be/) |
134
135## License
136
137_emoji-regex_ is available under the [MIT](https://mths.be/mit) license.
Note: See TracBrowser for help on using the repository browser.