Comments (12)
Actually the thing is, emoji.json in gemoji doesn't include \ufe0f
Β character at the end of such emojis. I don't know if that's an error in the data, but browsers and OS seem to render the emoji just fine without that character, however emoji regex separates the base from gender sequence.
Is this in the unicode spec, that emojis should be rendered correctly without fe0f, or browsers/OS trying their best?
from emoji-regex.
Can you post a code sample to reproduce the issue please? It seems to work for me:
const string = '\u{1F477}\u200D\u2640\uFE0F'; // 'π·ββοΈ'
console.log(string.match(emojiRegex())[0] === string);
// true
from emoji-regex.
I want to replace the matched emoji by wrapping it with an element. So my case is like this:
const text = 'π·ββοΈ'; // '\u{1F477}\u200D\u2640\uFE0F'
const replacedText = text.replace(emojiRegex(), (m) => {
return '<span>' + m + '</span>';
});
console.log(replacedText);
// '<span>π·</span>β'
it separates the zwj sequences and matches just with π·
from emoji-regex.
Which version of emoji-regex are you using? Your example works as expected in the latest version.
from emoji-regex.
Using v6.5.1. But I guess the problem is our emoji list which we got from gemoji When I converted the emojis to unicode, I realised that they don't include the gender part. I updated them with the correct ones, and the problem is solved.
Sorry for the hassle and thanks for your effort!
from emoji-regex.
emoji regex separates the base from gender sequence
Please provide a code example so I can reproduce this problem. The example in #27 (comment) seems to work fine.
from emoji-regex.
const text = "\u{1F477}\u200D\u2640";
console.log(text);
//> π·ββοΈ
const replacedText = text.replace(emojiRegex(), m => `<span>${m}</span>`);
console.log(replacedText);
//> <span>π·</span>β
from emoji-regex.
Thatβs the same example as before? It works as expected for me in the latest version: #27 (comment)
from emoji-regex.
Not really, the text is missing the last code point \ufe0f
, does it still work as expected?
from emoji-regex.
Your input text doesnβt include \uFE0F
, so why would you expect it in the output?
from emoji-regex.
Sorry if I wasn't clear enough. I wasn't expecting it to be in the output. The thing is, "\u{1F477}\u200D\u2640"
when logged directly to the console, can produce the correct gendered emoji, however when passed through the regex, it doesn't take "\u2640"
into account and only matches the male part.
const text = "\u{1F477}\u200D\u2640";
console.log(text);
//> π·ββοΈ
// female construction worker, it's displayed properly without \uFE0F character
const replacedText = text.replace(emojiRegex(), m => `<span>${m}</span>`);
console.log(replacedText);
//> <span>π·</span>β
// only the male construction worker is matched with emoji regex,
// and β (\u2640) character is left out
// which is basically "<span>\u{1F477}\u200D</span>\u2640"
// but I would expect it to be "<span>\u{1F477}\u200D\u2640</span>"
from emoji-regex.
Yes! I too have problem with a \uFE0F
#29
from emoji-regex.
Related Issues (20)
- Β© is recognised as an emoji HOT 2
- Typescript error when using require('emoji-regex') HOT 3
- Is this lib basically doing /\p{Emoji}|\p{Default_Ignorable_Code_Point}/gu ? HOT 3
- Question around choice of factory HOT 2
- Determine emoji type? HOT 2
- rename License file?
- some variations of emojis are not working with current version of emoji-regex library
- The face-exhaling emoji isn't matched correctly
- Node 20 LTS supports the new proposed RegExp flag linked in the source HOT 1
- Why does the second result return false? HOT 2
- Simplify build by leveraging rgi-emoji-regex-pattern HOT 1
- Certain emoji sequences are not recognized HOT 8
- Shopping Bag emoji doesn't match HOT 1
- typescript synthetic import HOT 2
- npm install emoji-regex returns MODULE_NOT_FOUND HOT 2
- Symbol # and Number 0-9 HOT 3
- .npmrc breaks local install HOT 1
- Does not match some emoji HOT 2
- How to use emoji-regex v10.0.0 with regexp unicode flag HOT 2
- Add changelog HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from emoji-regex.