klren0312 / daliy_knowledge

知识积累,正确使用方式是watch
21 stars 4 forks source link

正则使用关键词分割字符串(不区分大小写) #685

Open klren0312 opened 1 year ago

klren0312 commented 1 year ago
function doSplit(text, keyword) {
  const reg = new RegExp(`${keyword}`, 'gi')
  return text.replace(reg, v =>`\n${v}\n`).split('\n').filter(v => v)
}