你好,我给你写了一个例子,你看下:
var str = 'red|blue|green'var name = "redsee嗡嗡嗡|blue green'搜索<span>str</span>"
name = name.replace(new RegExp("(" + str + ")", "g"), "<span>$1</span>")
console.log(name)
希望是你想要的答案,如有疑问欢迎追问,望采纳~
<script type="text/javascript">var str = "1200[44_x][44_x]"
document.write(str.replace(/44/g, "132"))
</script>
我直接把44的3倍乘出来结果放进去了,没必要多写一句44*3