Discussions

 View Only
  • 1.  Replacing a quote in a string

    Posted 09-16-2021 13:11
    I have a use case where I have the following text in a field:

    {\"line\":\"twenty"\}

    The above is the output of the text field.

    I need to replace the \ characters above - I'm looking to get the following output:

    {"line":"twenty"}

    So i need a search and repalce for just the \ above.  The problem is this character is an escape character, and I have been fighting with searchandreplace to get this to work.  Current iteration:

    var text jsonStripped = SearchAndReplace($json, "\"", "");

    This strips the quotes and the \ character making the output:

    {line:twenty}

    I need to keep the quotes, so the text is valid JSON.  Any ideas?



    ------------------------------
    Ryan Haas
    ------------------------------


  • 2.  RE: Replacing a quote in a string

    Posted 09-16-2021 13:23
    try this


    var text jsonStripped = SearchAndReplace($json, "\\", "");

    ------------------------------
    Mark Shnier (YQC)
    mark.shnier@gmail.com
    ------------------------------