Skip to content

Instantly share code, notes, and snippets.

@aq1018
Created September 10, 2015 19:46
Show Gist options
  • Save aq1018/48865784774534a0977e to your computer and use it in GitHub Desktop.
Save aq1018/48865784774534a0977e to your computer and use it in GitHub Desktop.
Remove emoji from string.
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