更换双反斜线与JavaScript的一个反斜杠

编程入门 行业动态 更新时间:2024-10-14 18:22:28
本文介绍了更换双反斜线与JavaScript的一个反斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有以下问题:

我有一个执行一个AJAX请求到服务器的脚本,服务器返回 C:\在preVIEW备份\ 。然而,响应C:\\备份\\。不是一个真正的大问题,因为我只是想用单一换上双斜杠。我一直在寻找在这里堆栈,但我只能找到如何与双换上单反斜线,但我需要它周围的其他方法。

I have a script that executes an AJAX request to a server, the server returns C:\backup\ in the preview. However, the response is "C:\\backup\\". Not really a big deal, since I just thought to replace the double slashes with single ones. I've been looking around here on stack, but I could only find how to replace single backslashes with double ones, but I need it the other way around.

有人可以帮助我在这个问题上?

Can someone help me on this matter?

推荐答案

这应该这样做:C:\\备份\\代替(/ \\\\ /克,'\ \')

在正规前pression,一个 \ 必须逃到 \\ ,并在替换 \ 也。

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

更多推荐

更换双反斜线与JavaScript的一个反斜杠

本文发布于:2023-11-06 08:12:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1563159.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:斜杠   斜线   JavaScript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!