Last active
April 23, 2023 12:49
-
-
Save dnnsmnstrr/22bd0b0a5900032ee3d834e6b7698a7c to your computer and use it in GitHub Desktop.
A text formatter that replaces text with matching emoji
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function format(text) { | |
const emojimap = { | |
"β€οΈ": "love", | |
"π": "laughing", | |
"π": "awesome", | |
"π": "great", | |
"π": "crying", | |
"π": "smiling", | |
"π": "kiss", | |
"π₯": "fire", | |
"π₯Ί": "aww", | |
"π": "winking", | |
"π": "cool", | |
"π€": "thinking", | |
"π€·": "shrug", | |
"π": "ok", | |
"π": "boring", | |
"π©": "weary", | |
"π": "grinning", | |
"π": "praise", | |
"β¨": "sparkles", | |
"π": "look", | |
"π": "thanks", | |
"π": "cute", | |
"π": "heartbroken", | |
"π€": "hugging", | |
"π": "clapping", | |
"π€«": "shushing", | |
"π―": "100", | |
"π ": "home", | |
"π³": "tree", | |
"ποΈ": "beach", | |
"β°οΈ": "mountain", | |
"π’": "rollercoaster", | |
"π": "basketball", | |
"π": "swimming", | |
"π²": "food", | |
"π·": "wine", | |
"πΊ": "beer", | |
"ποΈ": "shopping", | |
"π΄": "cycling", | |
"π": "reading", | |
"βͺ": "church", | |
"π": "synagogue", | |
"π": "mosque" | |
}; | |
let formattedText = text; | |
// loop through the emojiMap and replace any matching word or phrase with the associated emoji | |
for (const [word, emoji] of Object.entries(emojiMap)) { | |
formattedText = formattedText.replace(new RegExp(word, "gi"), emoji); | |
} | |
return formattedText; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Generated by ChatGPT with this prompt: