js正则表达式匹配闭合标签

  let htmlStr = fs.readFileSync(__dirname + '/data.xml', 'utf8')
  htmlStr = htmlStr
    .replace(/&lt;/g, '<')
    .replace(/&gt;/g, '>')
    .replace(/&quot;/g, '"')
    .replace(/\n/g, '')
  let itemArr = []
  htmlStr.replace(/<item(([\s\S])*?)<\/item>/g, (word) => {
    console.log(word)
    itemArr.push(word)
    return word
  })

posted @ 2021-09-14 09:41  徐同保  阅读(455)  评论(0编辑  收藏  举报