emoji-regex
Advanced tools
Comparing version 6.1.0 to 6.1.1
{ | ||
"name": "emoji-regex", | ||
"version": "6.1.0", | ||
"description": "A regular expression to match all Emoji-only symbols as per the Unicode Standard.", | ||
"homepage": "https://mths.be/emoji-regex", | ||
"main": "index.js", | ||
"keywords": [ | ||
"unicode", | ||
"regex", | ||
"regexp", | ||
"regular expressions", | ||
"code points", | ||
"symbols", | ||
"characters", | ||
"emoji" | ||
], | ||
"license": "MIT", | ||
"author": { | ||
"name": "Mathias Bynens", | ||
"url": "https://mathiasbynens.be/" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/mathiasbynens/emoji-regex.git" | ||
}, | ||
"bugs": "https://github.com/mathiasbynens/emoji-regex/issues", | ||
"files": [ | ||
"LICENSE-MIT.txt", | ||
"index.js" | ||
], | ||
"directories": { | ||
"test": "tests" | ||
}, | ||
"scripts": { | ||
"build": "node scripts/generate-regex.js", | ||
"coverage": "istanbul cover --report html node_modules/.bin/_mocha scripts/generate-regex.js -- -u exports -R spec", | ||
"test": "mocha tests" | ||
}, | ||
"devDependencies": { | ||
"coveralls": "^2.11.1", | ||
"istanbul": "^0.3.5", | ||
"lodash.template": "^3.2.0", | ||
"mocha": "^2.1.0", | ||
"regexgen": "^1.0.0", | ||
"string.fromcodepoint": "^0.2.1", | ||
"unicode-tr51": "^6.0.0" | ||
} | ||
"name": "emoji-regex", | ||
"version": "6.1.1", | ||
"description": "A regular expression to match all Emoji-only symbols as per the Unicode Standard.", | ||
"homepage": "https://mths.be/emoji-regex", | ||
"main": "index.js", | ||
"keywords": [ | ||
"unicode", | ||
"regex", | ||
"regexp", | ||
"regular expressions", | ||
"code points", | ||
"symbols", | ||
"characters", | ||
"emoji" | ||
], | ||
"license": "MIT", | ||
"author": { | ||
"name": "Mathias Bynens", | ||
"url": "https://mathiasbynens.be/" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/mathiasbynens/emoji-regex.git" | ||
}, | ||
"bugs": "https://github.com/mathiasbynens/emoji-regex/issues", | ||
"files": [ | ||
"LICENSE-MIT.txt", | ||
"dist/index.js" | ||
], | ||
"scripts": { | ||
"build": "babel src -d dist", | ||
"clean": "rm -rf dist", | ||
"prepublish": "npm run clean && npm run build", | ||
"test": "mocha --compilers js:babel-register", | ||
"test:watch": "npm run test -- --watch" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.23.0", | ||
"babel-core": "^6.18.2", | ||
"babel-plugin-transform-unicode-property-regex": "^2.0.1", | ||
"babel-preset-es2015": "^6.18.0", | ||
"mocha": "^3.2.0", | ||
"unicode-tr51": "^8.0.1" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# emoji-regex [![Build status](https://travis-ci.org/mathiasbynens/emoji-regex.svg?branch=master)](https://travis-ci.org/mathiasbynens/emoji-regex) [![Code coverage status](http://img.shields.io/coveralls/mathiasbynens/emoji-regex/master.svg)](https://coveralls.io/r/mathiasbynens/emoji-regex) [![Dependency status](https://gemnasium.com/mathiasbynens/emoji-regex.svg)](https://gemnasium.com/mathiasbynens/emoji-regex) | ||
# emoji-regex [![Build status](https://travis-ci.org/mathiasbynens/emoji-regex.svg?branch=master)](https://travis-ci.org/mathiasbynens/emoji-regex) | ||
@@ -18,3 +18,3 @@ _emoji-regex_ offers a regular expression to match all emoji symbols (including textual representations of emoji) as per the Unicode Standard. | ||
```js | ||
var emojiRegex = require('emoji-regex'); | ||
const emojiRegex = require('emoji-regex'); | ||
// Note: because the regular expression has the global flag set, this module | ||
@@ -25,14 +25,29 @@ // exports a function that returns the regex rather than exporting the regular | ||
emojiRegex().test('🆘'); | ||
// → true | ||
emojiRegex().test('💩'); | ||
// → true | ||
emojiRegex().test('🇺🇸'); | ||
// → true | ||
const text = ` | ||
\u{231A}: ⌚ default emoji presentation character (Emoji_Presentation) | ||
\u{2194}\u{FE0F}: ↔️ default text presentation character rendered as emoji | ||
\u{1F469}: 👩 emoji modifier base (Emoji_Modifier_Base) | ||
\u{1F469}\u{1F3FF}: 👩🏿 emoji modifier base followed by a modifier | ||
`; | ||
var flag = '🇺🇸'; // flag for United States | ||
flag.match(emojiRegex())[0] == flag; | ||
// → true | ||
let match; | ||
while (match = emojiRegex().exec(text)) { | ||
const emoji = match[0]; | ||
console.log(`Matched sequence ${ emoji } — code points: ${ [...emoji].length }`); | ||
} | ||
``` | ||
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 | ||
``` | ||
## Author | ||
@@ -39,0 +54,0 @@ |
10021
6
5
29
60