Post
55
😊 This program is designed to remove emojis from a given text. It uses a regular expression (regex) pattern to match and replace emojis with an empty string, effectively removing them from the text. The pattern includes a range of Unicode characters that correspond to various types of emojis, such as emoticons, symbols, and flags. By using this program, you can clean up text data by removing any emojis that may be present, which can be useful for text processing, analysis, or other applications where emojis are not desired. 💻
import re
def remove_emojis(text):
# Define a function to remove emojis from a given text
emoji_pattern = re.compile(
"["
u"\U0001F600-\U0001F64F" # emoticons, such as smiling faces
u"\U0001F300-\U0001F5FF" # symbols and pictographs, like stars and hearts
u"\U0001F680-\U0001F6FF" # transport and map symbols, like cars and airplanes
u"\U0001F1E0-\U0001F1FF" # flags, like country flags
u"\U00002702-\U000027B0"
u"\U000024C2-\U0001F251"
"]+", flags=re.UNICODE
)
# Use the compiled pattern to replace emojis with an empty string
return emoji_pattern.sub(r'', text)