My problem is to remove emoji from a string, but not CJK (Chinese, Japanese, Korean) characters from a string using regex. I tried to use this regex:
REGEX =
I am using one based on this script.
def strip_emoji(text)
text = text.force_encoding('utf-8').encode
clean = ""
# symbols & pics
regex = /[\u{1f300}-\u{1f5ff}]/
clean = text.gsub regex, ""
# enclosed chars
regex = /[\u{2500}-\u{2BEF}]/ # I changed this to exclude chinese char
clean = clean.gsub regex, ""
# emoticons
regex = /[\u{1f600}-\u{1f64f}]/
clean = clean.gsub regex, ""
#dingbats
regex = /[\u{2702}-\u{27b0}]/
clean = clean.gsub regex, ""
end
Results:
irb> strip_emoji("