lutfijc35

Count Emojies

Oct 16th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function fancyCount(str){
  2.     return Array.from(str.split(/[\ufe00-\ufe0f]/).join("")).length;
  3. }
  4. function getCountEmojies(input){
  5.   let output = input.replace(/([\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2694-\u2697]|\uD83E[\uDD10-\uDD5D])/g, "");
  6. return fancyCount(input) - fancyCount(output)
  7. }
  8. // example
  9. getCountEmojies("Hello 👶 👧 there");
  10.  
  11. //output = 2
Advertisement
Add Comment
Please, Sign In to add comment