Replace double backslashes with a single backslash in javascript

后端 未结 2 1015
慢半拍i
慢半拍i 2021-01-04 14:27

I have the following problem:

I have a script that executes an AJAX request to a server, the server returns C:\\backup\\ in the preview. However, the r

2条回答
  •  一整个雨季
    2021-01-04 14:51

    This should do it: "C:\\backup\\".replace(/\\\\/g, '\\')

    In the regular expression, a single \ must be escaped to \\, and in the replacement \ also.

提交回复
热议问题