Created
September 10, 2015 19:46
-
-
Save aq1018/48865784774534a0977e to your computer and use it in GitHub Desktop.
Remove emoji from string.
This file contains hidden or 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
module EmojiTrimmer | |
MATCHERS = [ | |
# Emoticons | |
/[\u{1F600}-\u{1F6FF}]/, | |
# Miscellaneous Symbols and Pictographs | |
/[\u{1F300}-\u{1F5FF}]/, | |
# Transport And Map Symbols | |
/[\u{1F680}-\u{1F6FF}]/, | |
# flags (iOS) | |
/[\u{1F1E0}-\u{1F1FF}]/ | |
] | |
def self.trim(str) | |
MATCHERS.reduce(str) do |result, pattern| | |
result.replace(pattern, '') | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment