Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Sep 2011
    Posts
    184
    Thanks
    140
    Thanked 0 Times in 0 Posts

    String question replacing the single quote with a double quote

    Hello,

    I need your help.

    How can I convert the following input string:

    Code:
    var x = "A:\V10\db"
    into the output string of:

    Code:
    var y = "A:\\V10\\db"
    Thanks for all your help and support in advance.

    Cheers,

    Jay

  • #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,335
    Thanks
    11
    Thanked 588 Times in 569 Posts
    Code:
    var x = JSON.stringify("A:\V10\db");
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  • Users who have thanked rnd me for this post:

    jason_kelly (02-16-2014)

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Quote Originally Posted by rnd me View Post
    Code:
    var x = JSON.stringify("A:\V10\db");
    That outputs "A:V10db" (including the quotes).

    jason_kelly, the problem with the input string "A:\V10\db" is that the \ is treated as an escape character but is meaningless in this case as you are escaping V and d which is unnecessary. Is that input string generated from the server-side or from user input? If it's from the server-side and you want to set it to a js variable, then you need to escape the \ to \\ from the server-side. Can you post more code?

  • Users who have thanked glenngv for this post:

    jason_kelly (02-16-2014)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •