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