Created
March 18, 2018 09:20
-
-
Save pystub/3ef4241e9f6a44c07f69419c3262c818 to your computer and use it in GitHub Desktop.
pythong replacementer
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
#!/bin/python | |
import re | |
remappings = { | |
'\U0001F600': 'GRINNING FACE', | |
'\U0001F601': 'GRINNING FACE WITH SMILING EYES', | |
# and many more | |
} | |
def repl(m): | |
try: | |
return remappings[m.group(0)] | |
except KeyError: | |
return '' | |
text = 'Sphynx of black quartz, judge my vow \U0001F601' | |
print(text) | |
print(re.sub(r'[\U0001F600-\U0001F64F]', repl, text)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment