我有如下代码
return fetch(URI + 'api/brewing/1')
.then((response) => response.json())
.then((responseJson) => {
var parsedResponse = JSON.parse(responseJson["data"][0]["steps"]);
var stringData = JSON.stringify(parsedResponse);
})
.catch((error) => {
console.error(error);
});
}
并获取如下数据
将过滤器在温水浴中浸泡至少五分钟后,将其放入虹吸管顶部组件或料斗的底部,然后卡在料斗玻璃管的底部。底部组件。插入料斗、过滤器和所有部件。
我想将点和逗号分隔符后面的段落拆分为一个数组,以便我可以循环所有数据。我怎样才能做到这一点?谢谢。
最佳答案
我相信您想用点后跟逗号分割字符串:
var s = 'After soaking your filter in a warm water bath for at least five minutes, drop it into the bottom of your siphons top component, or hopper, and hook to the bottom of the hoppers glass tubing.,Fill your siphon bottom component.,Insert the hopper, filter and all.'
s = s.split('.,');
console.log(s);
或:使用正则表达式
var s = 'After soaking your filter in a warm water bath for at least five minutes, drop it into the bottom of your siphons top component, or hopper, and hook to the bottom of the hoppers glass tubing.,Fill your siphon bottom component.,Insert the hopper, filter and all.'
s = s.split(/(?:\.\,)/g);
console.log(s);
关于javascript - 将段落拆分为数组 javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55242551/