Skip to content

Instantly share code, notes, and snippets.

@pystub
Created March 18, 2018 09:20
Show Gist options
  • Save pystub/3ef4241e9f6a44c07f69419c3262c818 to your computer and use it in GitHub Desktop.
Save pystub/3ef4241e9f6a44c07f69419c3262c818 to your computer and use it in GitHub Desktop.
pythong replacementer
#!/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