html textarea array 正则

      this.failIdsStr = ''
      if (this.currentStatus === 3) {
        this.failIdsCount = this.tmpData.invalid_ids_count + this.tmpData.repeat_ids_count
        let tmpStr = (this.tmpData.invalid_ids + ',' + this.tmpData.repeat_ids).split(',').filter(Boolean)
        if (tmpStr.length > 0) {
          this.failIdsStr= tmpStr.join('\r\n')
        } 
      }
    changeMyTextarea(v) {
        let a = v.target.value
        let b = a.replace(/\n/g, ',')
        let c = a.split(/[\r\n]+/).join(',')

        let e = a
            .replace(/^[\r\n\s\uFEFF\xA0]+|[\r\n\s\uFEFF\xA0]+$/g, '')
            .split(/[\r\n]+/)
            .map(e => e.trim())
            .filter(Boolean)
            .join(',')
        console.log('a is..\n', a, '\nb is ..\n', b, '\ncis ..', c, '\ne is ..', e)
    },

猜你喜欢

转载自www.cnblogs.com/dhjy123/p/11891122.html