如何替换字符串中的字符(从文本格式到数组)
how to replace characters in a string (from text format to array)
我有一个问题和答案的文本文档,有10,000个,为了示例我会在下面添加一些
'
Severe cold | cold
A heavy massive vessel in which they pound with a pestle.|stupa
Monumental religious building in Indian architecture.|stupa
Commercial fish of the perch family.|zander
'
我们在这里和符号“|”后有问题答案
我需要转换成这种格式
['Severe cold'],['cold'],
['A heavy massive vessel in which they pound with a pestle'],['stupa'],
['Monumental religious building in Indian architecture'],['stupa'],
['Commercial fish of the perch family'],['zander']
我认为 string.split() 可能是您要查找的内容:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split
let arr = txt.split("|")
你的情况
我有一个问题和答案的文本文档,有10,000个,为了示例我会在下面添加一些
'
Severe cold | cold
A heavy massive vessel in which they pound with a pestle.|stupa
Monumental religious building in Indian architecture.|stupa
Commercial fish of the perch family.|zander
'
我们在这里和符号“|”后有问题答案
我需要转换成这种格式
['Severe cold'],['cold'],
['A heavy massive vessel in which they pound with a pestle'],['stupa'],
['Monumental religious building in Indian architecture'],['stupa'],
['Commercial fish of the perch family'],['zander']
我认为 string.split() 可能是您要查找的内容:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split
let arr = txt.split("|")
你的情况