汇总——字符串处理

1.去除注释内容

    removeStrNotes (value) {
      let result = ''
      const lines = value.split('\n')
      lines.forEach(val => { // 有注释去除注释,无注释直接使用,再去除两边空格
        const index = val.indexOf('//')
        const str = index === -1 ? val : val.substring(0, index)
        str.trim()
        result += str
      })
      return result
    }

 

posted @ 2019-09-03 15:27  桥南小院  阅读(176)  评论(0编辑  收藏  举报