Function: findEmoji()
findEmoji(
text
):EmojiMatch
|null
Finds emoji shortcodes in text, tokenized by spaces. The canonical short names such as "😃" are matched even if they are at the end of the text, but a text such as ":)" is only matched if it is followed by a space.
Parameters
• text: string
Returns
EmojiMatch
| null
Examples
assert(findEmoji(":man-facepalming:").emoji === "🤦♂️");
const input = "handles :) mid-string";
const result = findEmoji(input);
assert(result.position === "handles ".length);
assert(result.shortcode === ":)")
assert(result.emoji === "🙂");
assert([
input.slice(0, result.position),
result.emoji,
input.slice(result.position + result.shortcode.length)
].join("") === "handles 🙂 mid-string");
assert(findEmoji(":)") === null)