How to globally replace a forward slash in a JavaScript string?

后端 未结 10 2074
逝去的感伤
逝去的感伤 2020-11-28 22:05

How to globally replace a forward slash in a JavaScript string?

10条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-28 22:49

    Is this what you want?

    'string with / in it'.replace(/\//g, '\\');
    

提交回复
热议问题