I have a problem with replace emoji in string to string with unicode.
For example:
I have string:
const str = "My string is with emoji "
I need to convert this string to
const str = "My string EMOJI UNICODE is with emoji EMOJI UNICODE"
emoji unicode should look like : [e-1f60e]. Because I have function for converting string with unicode to string with emoji:
function convertEmoji(str) {
return str.replace(/\[e-([0-9a-fA-F]+)\]/g, (match, hex) =>
String.fromCodePoint(Number.parseInt(hex, 16))
);
}
console.log(convertEmoji('string [e-1f60e] sadfsadfsadf')); // "string sadfsadfsadf"