How can I remove the last emoji of a group of emojis in javascript?

Tags: , ,

Let’s say I have this 3 emojis in a string: 😀🎃👪

There are not any spaces or any other character except emojis in the string.

How can I remove the last emoji in javascript?


Ok, here is how I solved it:

function deleteEmoji(emojiStr) {
    let emojisArray = emojiStr.match(/([uD800-uDBFF][uDC00-uDFFF])/g);
    emojisArray = emojisArray.splice(0, emojisArray.length - 1);
    return emojisArray.join("");
let emojitext = "😀🎃👪";

Source: stackoverflow