From twitter feed I am getting below code. How to convert this twitter unicode to emoji in javascript?
(&# 128079;&# 128079;&# 128079;&# 128079;)
to
👏👏👏👏
How to show the emoji symobol using javascript?
You could use the regex /&# (\\w+);/
to get each Code point to a capturing group. Then use String.fromCodePoint
method in the replacement function of replace
to get the emojis like this:
const str = '&# 128079;&# 128079;&# 128079;&# 128079;' const emojiStr = str.replace(/&# (\\w+);/g, (m, c1) => String.fromCodePoint(c1)) console.log(emojiStr)
( Regex demo )
If you just want to display it on the DOM, you can just remove the space ( \\s
) and set the escaped string to innerHTML
const str = '&# 128079;&# 128079;&# 128079;&# 128079;' document.getElementById('display').innerHTML += str.replace(/\\s/g, '')
<span id='display'></span>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.