Vue regular expression replacement

clipboard.png
the requirement is that the AutoComplete component of Vue input abc will go to the background to take out all the existing abc (case-insensitive) and highlight

highlightData: function (data, propShow, propOrigin, highlight) {
        data.forEach(item => {
          // 
          let replaceReg = new RegExp(highlight, "gi")
          // v-html
          let replaceString = "<span class="color-primary">" + highlight + "</span>"
          // 
          item[propShow] = item[propOrigin].replace(replaceReg, replaceString)
        })
        return data
      },

that"s what I wrote before, but it turns the original ABC into abc and highlights it. It"s hard? How to write


Why use replace? I think we should use test or match. Of course, it's not impossible for you to use replace.
let replaceReg = new RegExp (highlight, 'gi')
let replaceString =' < span class= "color-primary" > $& '
item [propShow] = item [propOrigin]. Replace (replaceReg, replaceString)


but this will turn the original ABC into abc and highlight
'abcABC'.replace(/abc/gi,(val) =>`

${val}

`) //"

abc

ABC

"
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e875bb-e4e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e875bb-e4e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?