Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
EmojiRemove.py
# #!/usr/bin/env python
# xmlファイル内の絵文字除去用スクリプト
import sys
import re
# チェック元ファイル
f = open(sys.argv[1])
# 絵文字除去後のファイル
new_file = open('EmojiRemovedFile.xml', 'a')
# 正規表現パターンを構築
emoji_pattern = re.compile("["
u"\U0001F600-\U0001F64F"
u"\U0001F300-\U0001F5FF"
u"\U0001F680-\U0001F6FF"
u"\U0001F1E0-\U0001F1FF"
"]+", flags=re.UNICODE)
# 1行ずつ処理
for line in f:
f.write(emoji_pattern.sub(r'@emoji', line))
f.close();
new_file.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment