Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4021356
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:20:29+00:00 2026-05-20T10:20:29+00:00

I want to unescape all nested quotes within a string. The following examples are

  • 0

I want to unescape all nested quotes within a string. The following examples are given as literal (C# or F#) style .NET strings, not surround by quotes:

  • [(\"hello world\", 2); (\"goodbye\", 3)] doesn’t change
  • [(\"hello\"world\", 2); (\"go\"o\"d\"bye\", 3)] becomes [(\"hello\\\"world\", 2); (\"go\\\"o\\\"d\\\"bye\", 3)]

I’m not sure whether this can be done with Regex(pattern, "\\\"").Replace but I am still too much of a regex novice for the solution to come easily to me. Any solution, regex if possible, would be appreciated.

Edit

Thanks for feedback so far from everyone, I see now that since there is no distinguishing between opening and closing quotes, the syntax is ambiguous and the direction I was going can’t be worked. So I will give the big picture in hopes of a some new direction.

I am working on a project which converts F# Quotations into F# source code strings. So a I have function source: Expr -> string which should produce a string which when printed to a typical console like FSI is valid F# code. For this problem, I am looking to improve the way Value quotation expressions are sprinted. Currently I do something like the following (see starting at line 312 of http://code.google.com/p/unquote/source/browse/trunk/Unquote/Sprint.fs for real code):

match expr with
| Value(o, _) ->
  match o with
  | null -> "null"
  | _ -> sprintf "%A" o

But then, for example, I get the following

> <@ "\r\"\n" @> |> source |> stdout.WriteLine;;
"
"
"
val it : unit = ()

instead of the desired

> <@ "\r\"\n" @> |> source |> stdout.WriteLine;;
"\r\"\n"
val it : unit = ()

If I only needed to consider Values encapsulating strings, that would be easy with something like

let unescape s =
    ["\\","\\\\"
     "\b","\\b"
     "\n","\\n" 
     "\r","\\r" 
     "\t","\\t"
     "\"", "\\\""]
    |> List.fold (fun (s:string) (before, after) -> s.Replace(before, after)) s

The problem is, any object may be a Value, including those with structured formats used by sprint "%A" which I’d like to leverage as much as possible (so while I could go through and handle a finite set of cases like lists, arrays, tuples, and so forth, that isn’t as general as I’d like it to be): so sprinting a list<string*int> Value needs special care for example, since we need to distinguish between quotes which should be displayed literally for string construction, versus those which should be displayed as escape sequences.

Any ideas welcome, thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:20:30+00:00Added an answer on May 20, 2026 at 10:20 am

    I don’t think this can be done as the question stands currently, because the syntax you want to process is ambiguous. For example, it is not possible to tell whether:

    [ (\"hello\"world\", 2); (\"good\"bye\", 3)]

    Should be turned into list with two elements:

    [ (\"hello\\\"world\", 2); (\"good\\\"bye\", 3)]

    .. or a list with just single element (with text containing some funky symbols):

    [ (\"hello\\\"world\\\", 2); (\\\"good\\\"bye\", 3)]

    It seems that you’re trying to do something with the output printed by F# Interactive. Maybe there is some better way to print what you need so that you can avoid ambiguity. Could you add some big picture?

    If you need to process any list/tuple data structure, then it will be probably easier to write it using F# reflection API (see Microsoft.FSharp.Reflection namespace) than by parsing F# output. (Or you can use the API to write your own unambiguous printer)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I want to replace the following string within a textfile: document.write(unescape(%3Cscript src='
I want to unescape the following string: '\u00020\u0002Standard\u00023\u0002Doe John\u000169\u0002\u0010\u0002Lorem\u0002\u0011\u0002Ipsum\u0002\u0014\u0002' Javascript's unescape function works OK,
In the following input string: {$foo}foo bar \\{$blah1}oh{$blah2} even more{$blah3} but not{$blarg}{$why_not_me} I am
want to know why String behaves like value type while using ==. String s1
want to rewrite urls like site.com/software to wp-content/themes/dir/software.php and something is not working.. Here's
want to ask user to input something but not want to wait forever. There
I am using PHP to match the following data type : [[1200,135],[127,13]] I want
I want to write a wrapper bash script, and to pass all arguments to
I Splitted the Url string into n number , now i want it to
Hi I want to replace document.write(unescape(%3Cscript src=' + gaJsHost + google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E)); with (function()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.