drhg24275 2016-09-19 14:35
浏览 396
已采纳

如何在Golang中使用正则表达式替换字符串中的表情符号字符

I want to replace all of emoji s in string by regex in golang.

Like this :

Thats a nice joke

  • 写回答

2条回答 默认 最新

  • dongzhijing8202 2016-09-19 16:17
    关注

    You seem to want to match a specific set of emojis.

    Use

    package main
    
    

    import (
    "fmt"
    "regexp"
    )

    func main() {
    var emojiRx = regexp.MustCompile([\x{1F600}-\x{1F6FF}|[\x{2600}-\x{26FF}])
    var s = emojiRx.ReplaceAllString("Thats a nice joke

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?