I often need to strip emoji from strings to prevent them from messing up other handling. I’ve been compiling regular expressions and I think I finally have all the bases covered.

This example is in Ruby, but the regular expressions are easy to adapt to any language:

[gist bf121c6a199bc20c7f3085c50cd6d175]

I’ve already ported this to Swift and Python, and put together a
repo
intended to keep these as living documents that are
updated to keep up with new emoji. If you’re into this kind of thing,
please make pull requests as you discover new edge cases. You can
create PRs against the README.md, which contains the main regular
expression, or against any of the languages you use. And if you port
this to any other language, please add a routine to the repo!


Leave a Reply

Your email address will not be published. Required fields are marked *