code: public static int countEmojis(String text) {
  
  		String htmlifiedText = htmlify(text);
  		// regex to identify html entitities in htmlified text
  		Matcher matcher = htmlEntityPattern.matcher(htmlifiedText);
  
  		int counter = 0;
  		while (matcher.find()) {
  			String emojiCode = matcher.group();
  			if (isEmoji(emojiCode)) {
  				counter++;
  			}
  		}
  		return counter;
  	}
docs: Counts valid emojis passed string
  
  @param text String to count emoji characters in.
  @return returns count of emojis