汇总——字符串处理

1.去除注释内容

    removeStrNotes (value) {
      let result = ''
      const lines = value.split('
')
      lines.forEach(val => { // 有注释去除注释,无注释直接使用,再去除两边空格
        const index = val.indexOf('//')
        const str = index === -1 ? val : val.substring(0, index)
        str.trim()
        result += str
      })
      return result
    }
原文地址:https://www.cnblogs.com/wheatCatcher/p/11453299.html