Home  >  Q&A  >  body text

angular.js - angular中是否如何判断一段文本是否包含emoji?

在项目需要实现从服务端获取到的文本信息中把emoji换成图片展示,但是服务端返回的格式类似这种
eg:[pig_4] [pig_5] [pig_4] [pig_5] [pig_5],我应该怎么把相对应的[pig_4]换成对应的图片呢?用截取??

淡淡烟草味淡淡烟草味2731 days ago653

reply all(2)I'll reply

  • 淡淡烟草味

    淡淡烟草味2017-05-15 17:09:23

    You can use regular expressions to implement the analysis yourself
    Or see if there is an emoji library, https://github.com/search?l=J...
    Then make it filter(ng1)/pipe(ng2)

    reply
    0
  • 迷茫

    迷茫2017-05-15 17:09:23

    It’s hard to judge, emoji strings basically all start with /, and some special characters also start with /, so if you can accurately distinguish whether they are special characters, you can judge. Regex is very simple to write!

    reply
    0
  • Cancelreply