首页 > 解决方案 > How to count emoji in a bunch text react native?

问题描述

I'm new to react-native, I want to analyze my text in the following criteria

I have my string like this
happy Morning Tuesday 😜✌ðŸ», Today I'm had my breakfast

In this string this one is emoji Unicode character😜✌ðŸ».I want to do the following analysis

  1. Total number of emojis,
  2. count number of times used for every emoji

Can you help me, I want to do in react native, can you suggest any packages or any references for me

标签: javascriptandroidreact-nativemobile

解决方案


试试下面的

如果您不想使用任何第三方库,请尝试

function getEmojiChars(text) {

console.log(text.match(/\ud83c[\udf00-\udfff]|\ud83d[\udc00-\ude4f]|\ud83d[\ude80-\udeff]/g))  ;
}

另请参阅以下链接


推荐阅读