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
    178
    Thanks
    138
    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,184
    Thanks
    10
    Thanked 569 Times in 550 Posts
    Code:
    var x = JSON.stringify("A:\V10\db");
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/1/19) IE7:0.2, IE8:6.7, IE11:7.4, IE9:3.8, IE10:4.4, FF:18.3, CH:43.6, SF:7.8, MOBILE:27.5

  • 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
    10,965
    Thanks
    0
    Thanked 236 Times in 233 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
    •