-
-
Save melihkocaturk/47dcf4ec2c282214b967de2e80a64417 to your computer and use it in GitHub Desktop.
Strip emoji
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
# this scrubs emoji sequences from a string - i think it covers all of them | |
def strip_emoji ( str ) | |
str = str.force_encoding('utf-8').encode | |
clean_text = "" | |
# emoticons 1F601 - 1F64F | |
regex = /[\u{1f600}-\u{1f64f}]/ | |
clean_text = str.gsub regex, '' | |
#dingbats 2702 - 27B0 | |
regex = /[\u{2702}-\u{27b0}]/ | |
clean_text = clean_text.gsub regex, '' | |
# transport/map symbols | |
regex = /[\u{1f680}-\u{1f6ff}]/ | |
clean_text = clean_text.gsub regex, '' | |
# enclosed chars 24C2 - 1F251 | |
regex = /[\u{24C2}-\u{1F251}]/ | |
clean_text = clean_text.gsub regex, '' | |
# symbols & pics | |
regex = /[\u{1f300}-\u{1f5ff}]/ | |
clean_text = clean_text.gsub regex, '' | |
end | |
def test_strip_emoji | |
f = File.open("emoji.txt", "r") | |
f.each_line do |line| | |
puts strip_emoji_full(line) | |
end | |
f.close | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment