Sometimes, we want to remove emoji code using JavaScript.
In this article, we’ll look at how to remove emoji code using JavaScript.
How to remove emoji code using JavaScript?
To remove emoji code using JavaScript, we use the replace
method.
For instance, we write
const s = "Smile😀".replace(/\p{Emoji}/gu, "");
to call replace
on "Smile😀"
with the \p{Emoji}
pattern to match emojis.
We use the g
flag to replace all matches with empty strings.
And we use the u
flag to match Unicode characters.
Conclusion
To remove emoji code using JavaScript, we use the replace
method.