title: Javascript Find Emoji in String and Parse
body: <p>After TONS of research, I have found how to parse emoji in realtime using the Twemoji library.</p>
  
  <p>Now, I need to figure out how to identify if there's emoji within some text, grab the position of that emoji and execute the parsing function.</p>
  
  <p>Some example text can be</p>
  
  <pre><code>It is a great day .
  </code></pre>
  
  <p>Need to find the  within the whole string and use the following function to get its hex code, return the surrogate pairs and parse with the Twemoji library.</p>
  
  <pre><code>function entityForSymbolInContainer(selector) {
      var code = data.message.body.codePointAt(0);
      var codeHex = code.toString(16);
      while (codeHex.length &lt; 4) {
          codeHex = "0" + codeHex;
      }
  
      return codeHex;
  }
  
  // Get emoji hex code
      var emoji = entityForSymbolInContainer(data.message.body);
  // For given an HEX codepoint, returns UTF16 surrogate pairs
      var emoji = twemoji.convert.fromCodePoint(emoji);
  // Given a generic string, it will replace all emoji with an &lt;img&gt; tag
      var emoji = twemoji.parse(emoji);
  </code></pre>
  
  <p>I am using the following check to see if there's emoji within the text. Problem is that for a simple grinning face () it doesn't alert me. However, if I type in the "shirt and tie" () it will alert me to that.</p>
  
  <pre><code>var string = "It is a great day .";
  var emojiRegex = /([\uE000-\uF8FF]|\uD83C[\uDF00-\uDFFF]|\uD83D[\uDC00-\uDDFF])/g;
  
  if (string.match(emojiRegex)) {
      alert("emoji found");
  }
  </code></pre>
  
  <p>Please help on the issue of the regex not picking up the emoji. After that, I should be able to just find that within the string.</p>
  
  <p>Thank you!</p>