Javascript and backslashes replace

前端 未结 7 1467
伪装坚强ぢ
伪装坚强ぢ 2020-11-27 07:50

here is my string:

var str = \"This is my \\string\";

This is my code:

var replaced = str.replace(\"/\\\\/\", \"\\\\\\\\\")         


        
相关标签:
7条回答
  • 2020-11-27 08:52

    In case you have multiple instances or the backslash:

    str.split(String.fromCharCode(92)).join(String.fromCharCode(92,92))
    
    0 讨论(0)
提交回复
热议问题