How do I remove emoji from string

前端 未结 10 2177
你的背包
你的背包 2020-11-28 10:44

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 =         


        
10条回答
  •  感情败类
    2020-11-28 11:27

    Karol S already provided a solution, but the reason might not be clear:

    "\u1F600" is actually "\u1F60" followed by "0":

    "\u1F60"    # => "ὠ"
    "\u1F600"   # => "ὠ0"
    

    You have to use curly braces for code points above FFFF:

    "\u{1F600}" #=> "

提交回复
热议问题