<script>
            let a = ['123','asd']
            //允许中间有空格
              a = a.map(item => {
                let arr = item.split('').join('\ {0,}')
                return arr
            })
            //
            let str = "saldnkjasbdkjasd 123dasdasd4123sdasd11asd123daaaa"
            let  re = new RegExp(`(${a.join('|')})`,'ig')
           let res = str.replace(re, function(word, index,sss){
               console.log(word, index,sss,"index")
                return '<span >' + word + '</span>'
            })
            
            console.log(res,"res")
        </script>

相关文章:

  • 2022-12-23
  • 2022-03-02
  • 2021-12-04
  • 2021-10-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-01
  • 2021-05-26
  • 2022-12-23
  • 2022-12-23
  • 2021-11-24
  • 2021-09-06
  • 2021-07-21
相关资源
相似解决方案