source: trip-planner-front/node_modules/emoji-regex/README.md@ fa375fe

Last change on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.6 KB
Line 
1# emoji-regex [![Build status](https://travis-ci.org/mathiasbynens/emoji-regex.svg?branch=master)](https://travis-ci.org/mathiasbynens/emoji-regex)
2
3_emoji-regex_ offers a regular expression to match all emoji symbols (including textual representations of emoji) as per the Unicode Standard.
4
5This repository contains a script that generates this regular expression based on [the data from Unicode v12](https://github.com/mathiasbynens/unicode-12.0.0). 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');
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
52To match emoji in their textual representation as well (i.e. emoji that are not `Emoji_Presentation` symbols and that aren’t forced to render as emoji by a variation selector), `require` the other regex:
53
54```js
55const emojiRegex = require('emoji-regex/text.js');
56```
57
58Additionally, in environments which support ES2015 Unicode escapes, you may `require` ES2015-style versions of the regexes:
59
60```js
61const emojiRegex = require('emoji-regex/es2015/index.js');
62const emojiRegexText = require('emoji-regex/es2015/text.js');
63```
64
65## Author
66
67| [![twitter/mathias](https://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") |
68|---|
69| [Mathias Bynens](https://mathiasbynens.be/) |
70
71## License
72
73_emoji-regex_ is available under the [MIT](https://mths.be/mit) license.
Note: See TracBrowser for help on using the repository browser.