javascript - Better Way to Escape Dollar Signs in the String Used By String.prototype.replace

前端 未结 3 1110
时光说笑
时光说笑 2020-12-19 00:02

I want to replace a string by another. I found when the replaceValue contains \"$\", the replace will fail. So I am trying to escape \"$\" by

3条回答
  •  抹茶落季
    2020-12-19 00:54

    Unfortunately, nothing you can do about it.
    It's just how JavaScript works with regular expressions.

    Here's a good article with the list of all replacement patterns you should be aware of: http://es5.github.io/#x15.5.4.11

提交回复
热议问题