【发布时间】:2019-01-20 00:41:28
【问题描述】:
我有这样的文字:
let text = ":wink: Is that true? :like: I never heard about that, as I know some country like: VN, Indonesia, ThaiLan".
:wink: 和 :like: 是显示表情符号的代码。现在我使用 split 来转换成这样的数组:
const myArray = text.split(':')
结果:
myArray = ["", "wink", " Is that true? ", "like", " I never heard about that, as I know some country like", " VN, Indonesia, ThaiLan"]
如您所见,字符 ':' 消失了,如何在从文本转换为数组时保留 ':',在这种情况下,我期望的结果应该是:
myArray = [":wink:", " Is that true? ", ":like:", " I never heard about that, as I know some country like:", " VN, Indonesia, ThaiLan"]
【问题讨论】:
-
这个数组真的是你的目标,还是你的目标是用表情符号替换
:wink:和:like:? (构建该数组可能不是执行后者的正确方法。) -
你想把
VN, Indonesia, ThaiLan放在最后吗? -
stackoverflow.com/questions/51378198/… 这是我的主要问题:D
标签: javascript