double-quotes

Is there any practical reason to use quoted strings for JSON keys?

时光怂恿深爱的人放手 提交于 2019-11-26 09:07:52
问题 According to Crockford\'s json.org, a JSON object is made up of members , which is made up of pairs . Every pair is made of a string and a value , with a string being defined as: A string is a sequence of zero or more Unicode characters, wrapped in double quotes, using backslash escapes. A character is represented as a single character string. A string is very much like a C or Java string. But in practice most programmers don\'t even know that a JSON key should be surrounded by double quotes,

Split string on commas but ignore commas within double-quotes?

扶醉桌前 提交于 2019-11-26 07:44:04
问题 I have some input that looks like the following: A,B,C,\"D12121\",E,F,G,H,\"I9,I8\",J,K The comma-separated values can be in any order. I\'d like to split the string on commas; however, in the case where something is inside double quotation marks, I need it to both ignore commas and strip out the quotation marks (if possible). So basically, the output would be this list of strings: [\'A\', \'B\', \'C\', \'D12121\', \'E\', \'F\', \'G\', \'H\', \'I9,I8\', \'J\', \'K\'] I\'ve had a look at some

Why isn't tilde (~) expanding inside double quotes? [duplicate]

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 04:28:58
问题 This question already has answers here : “~/Desktop/test.txt: No such file or directory” (2 answers) Closed last year . I want to check whether or not the hidden .git folder exists. First thought was to use: if [ -d \"~/.git\" ]; then echo \"Do stuff\" fi But the -d apparently does not look for hidden folders. 回答1: The problem has to do with the tilde being within double quotes. To get it expanded, you need to put the tilde outside the quotes: if [ -d ~/".git" ]; then # note tilde outside

Escaping separator within double quotes, in awk

夙愿已清 提交于 2019-11-26 02:38:23
问题 I am using awk to parse my data with \",\" as separator as the input is a csv file. However, there are \",\" within the data which is escaped by double quotes (\"...\"). Example filed1,filed2,field3,\"field4,FOO,BAR\",field5 How can i ignore the comma \",\" within the the double quote so that I can parse the output correctly using awk? I know we can do this in excel, but how do we do it in awk? 回答1: It's easy, with GNU awk 4 : zsh-4.3.12[t]% awk '{ for (i = 0; ++i <= NF;) printf "field %d =>

Escape double quotes in string

邮差的信 提交于 2019-11-26 01:45:53
问题 Double quotes can be escaped like this: string test = @\"He said to me, \"\"Hello World\"\". How are you?\"; But this involves adding character \" to the string. Is there a C# function or other method to escape double quotes so that no changing in string is required? 回答1: No. Either use verbatim string literals as you have, or escape the " using backslash. string test = "He said to me, \"Hello World\" . How are you?"; The string has not changed in either case - there is a single escaped " in

How to add double quotes to a string that is inside a variable?

孤街醉人 提交于 2019-11-26 01:45:05
问题 I have variable like: string title = string.empty; My need is that whatever string is passed to it I have to display the content inside a div with in a double quotes. So I have written something like: ... ... <div>\"+ title +@\"</div> ... ... But how to add the double quotes here? So that it will display like : \"How to add double quotes\" 回答1: You need to escape them by doubling them (verbatim string literal): string str = @"""How to add doublequotes"""; Or with a normal string literal you

How can I make Java print quotes, like “Hello”?

霸气de小男生 提交于 2019-11-26 01:16:50
问题 How can I make Java print \"Hello\" ? When I type System.out.print(\"Hello\"); the output will be Hello . What I am looking for is \"Hello\" with the quotes( \"\" ). 回答1: System.out.print("\"Hello\""); The double quote character has to be escaped with a backslash in a Java string literal. Other characters that need special treatment include: Carriage return and newline: "\r" and "\n" Backslash: "\\\\" Single quote: "\'" Horizontal tab and form feed: "\t" and "\f" The complete list of Java

What is the difference between String.Empty and “” (empty string)?

狂风中的少年 提交于 2019-11-25 22:33:24
问题 In .NET, what is the difference between String.Empty and \"\" , and are they interchangable, or is there some underlying reference or Localization issues around equality that String.Empty will ensure are not a problem? 回答1: In .NET prior to version 2.0, "" creates an object while string.Empty creates no object ref , which makes string.Empty more efficient. In version 2.0 and later of .NET, all occurrences of "" refer to the same string literal, which means "" is equivalent to .Empty , but

What is the difference between &#39; and " in Prolog?

≡放荡痞女 提交于 2019-11-25 22:07:31
问题 I am new to Prolog and noticed that \' and \" give different behavior, but am curious as to why. Specifically, when loading a file, ?- [\'test1.pl\']. works, while ?- [\"test1.pl\"]. doesn\'t. 回答1: Single quoted items are always atoms. The meaning of double quotes depends on the Prolog flag double_quotes : atom — with this value "a" = a . Nowadays, this is rarely used. But you will find Prolog books where ["abc.pl"] is written. codes — a list of character codes. This is frequently the default

How do I put double quotes in a string in vba?

喜你入骨 提交于 2019-11-25 21:58:15
问题 I want to insert an if statement in a cell through vba which includes double quotes. Here is my code: Worksheets(\"Sheet1\").Range(\"A1\").Value = \"=IF(Sheet1!B1=0,\"\",Sheet1!B1)\" Due to double quotes I am having issues with inserting the string. How do I handle double quotes? 回答1: I find the easiest way is to double up on the quotes to handle a quote. Worksheets("Sheet1").Range("A1").Formula = "IF(Sheet1!A1=0,"""",Sheet1!A1)" Some people like to use CHR(34)*: Worksheets("Sheet1").Range(