How to count emoji in a text or string

后端 未结 4 935
渐次进展
渐次进展 2021-01-18 07:49

How to count EMOJI in a string or text line and display the output, how many emoji are in the text line or string?

For example:

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-18 08:31

    One option would be to compare the length of the input string against the length of the same string with all Emoji characters removed:

    function fancyCount(str){
        return Array.from(str.split(/[\ufe00-\ufe0f]/).join("")).length;
    }
    
    var input = "Hello 

提交回复
热议问题