getString(str, keyword, arr, index=2) {
let newArr = arr;
let nowIndex = index || 2;
while (str.indexOf(`${nowIndex}${keyword}`) > -1) {
nowIndex == 2 ? newArr.push(str.split(`${nowIndex}${keyword}`)[0]) : newArr.push(`${nowIndex - 1}${keyword}` + str.split(`${nowIndex}${keyword}`)[0]);
str = str.split(`${nowIndex}${keyword}`)[1]
nowIndex += 1
}
nowIndex != 2 ? newArr.push(`${nowIndex - 1}${keyword}${str}`) : '';
let outArr = nowIndex == 2 ? [str] : newArr;
return outArr;
}
js实现段落分格字符,分段落
最新推荐文章于 2023-08-03 14:42:54 发布