I need to manually delete an emoji from a string. The problem here is that emojis are presented by multiple unicode symbols, for example:
'🔥'.split('') // output ['uD83D', 'uDD25']
I could check if the previous one is uD83D
and delete both, because it seems like every emoji starts with it, but then I found out that some emojis could contain multiple emojis:
'🧑💻'.split('') // ['uD83E', 'uDDD1', '', 'uD83D', 'uDCBB']
Though the pattern here is clear, I wonder if there is a best practice for detecting them?
3
Answers
Found a solution based on Intrl.Segmenter(). For those who interested, here is an article
You have to use replace method with your string to replace with empty ”.
For example :
or
This methods works for me
But it will also remove other non-ascii characters.