Replace all backslashes in a string with a pipe

后端 未结 2 1574
不知归路
不知归路 2020-12-06 04:48

I have the string: \\rnosapmdwq\\salesforce\\R3Q\\OutputFiles\\Archive

I\'m getting a unrecognized escape sequence when I try to send this to a .NET web service.

相关标签:
2条回答
  • 2020-12-06 05:12

    The correct syntax would be: Path = Path.replace(/\\/g, "|");

    Working example at: http://jsfiddle.net/eDKej/.

    Example (extra code for demonstration purposes only):

    var Path = $("#path").text();
    Path  = Path.replace(/\\/g, "|");
    $("#new-path").append(Path);
    
    0 讨论(0)
  • 2020-12-06 05:23

    You don't need to make a regex a string, and it helps having that first / in there

    Path = Path.replace(/\\/g, "|")
    
    0 讨论(0)
提交回复
热议问题