quotation-marks

DOS Batch : dealing with double quotes from XML files

你说的曾经没有我的故事 提交于 2019-12-13 04:44:35
问题 I have written the code below to read XML files (file_1.xml and file_2.xml) and to extract the string between tags and to write it down into a TXT file. The issue is that some strings include double quotation marks and the program then takes these characters as being proper instructions (not part of the strings)... Content of file_1.xml : <AAA>C086002-T1111</AAA> <AAA>C086002-T1222 </AAA> <AAA>C086002-TR333 "</AAA> <AAA>C086002-T5444 </AAA> Content of file_2.xml : <AAA>C086002-T5555 </AAA>

contains quotation mark java

久未见 提交于 2019-12-13 03:58:26
问题 how to I add an argument to check if a string contains ONE quotation mark ? I tried to escape the character but it doesn't work words[i].contains() EDIT: my bad, got some unclosed brackets, works fine now 回答1: words[i].matches("[^\"]*\"[^\"]*") That is: any non-quotes, a quote, any non-quotes. 回答2: You could use something like this: words[i].split("\"").length - 1 That would give you the amount of " s in your string. Therefore, just use: if (words[i].split("\"").length == 2) { //do stuff }

Search for quotes with regular expression

主宰稳场 提交于 2019-12-13 03:56:31
问题 I'm looking for a way to search a text file for quotes made by author and then print them out. My script so far: import re #searches end of string print re.search('"$', 'i am searching for quotes"') #searches start of string print re.search('^"' , '"i am searching for quotes"') What I would like to do import re ## load text file quotelist = open('A.txt','r').read() ## search for strings contained with quotation marks re.search ("-", quotelist) ## Store in list or Dict Dict = quotelist ##

int* to Constant Array

偶尔善良 提交于 2019-12-11 03:48:34
问题 I asked this question: Array Equivalent of Bare-String To which the answer was C++ doesn't provide this functionality for const int* s. Which is disappointing. So my question then is: In practice how do I get around this limitation? I want to write a struct like this: struct foo{ const char* letters = "abc"; const int* numbers = ??? }; I cannot: &{1, 2, 3} cause I can't take the address of an r-value array<int, 3>{{1, 2, 3}}.data() cause the memory is cleaned up immediately after

echo nested quotation marks in tcsh

时光怂恿深爱的人放手 提交于 2019-12-10 15:59:39
问题 I have a tcsh script that generates a text file. One of the lines in the text file is: bla bla bla 'foo foo foo "bar bar bar"': etc etc; Note the nested ' and " and also the : and ; that must be there. The : and ; require the whole string to be surrounded by quotation marks. However, if I do that, I have trouble escaping the quotation marks. The command is: echo "bla bla bla 'foo foo foo "bar bar bar"': etc etc;" >> outfile How can I escape the quotation marks around bar bar bar so that they

Python CSV : field containing quotation mark at the beginning

孤者浪人 提交于 2019-12-07 16:19:39
问题 I am trying to read a CSV file containing a line like following: test,"test,"test,test,test,test There is a problems with the quotation marks (There are six fields, but they are retrieved as five fields, as "test,"test is read as a single field). I have tried modifying the entry as follows, but I still can't retrieve the quotation mark: test,""test,""test,test,test,test # quotation marks disappear when the entry is read. test,\"test,\"test,test,test,test # backslashes are also retrieved;

Removing whitespace-characters, except inside quotation marks in PHP?

纵然是瞬间 提交于 2019-12-06 04:44:29
问题 I need to remove all whitespace from string, but quotations should stay as they were. Here's an example: string to parse: hola hola "pepsi cola" yay output: holahola"pepsi cola"yay Any idea? I'm sure this can be done with regex, but any solution is okay. 回答1: We could match strings or quotations with [^\s"]+|"[^"]*" So we just need to preg_match_all and concatenate the result. Example: $str = 'hola hola "pepsi cola" yay'; preg_match_all('/[^\s"]+|"[^"]*"/', $str, $matches); echo implode('',

How to parse quotation marks and comma in c++

青春壹個敷衍的年華 提交于 2019-12-06 04:29:21
I have a huge file to parse. Previously, it was separated by either space or comma and I used sscanf(string, "%lf %lf ", &aa, &bb); to get the data into my program. But now the data format is changed to "122635.670399999","209705.752799999" , with both comma and quotation marks. And I have no idea how to deal with it. Actually, my previous code was found online and I had a really hard time finding a proper document for this kind of problems. It will be great if you can recommend some to me. Thanks. Rather than read a string, then remove the commas and quotes from the strings, and finally

Replacing quotation marks in Javascript?

谁都会走 提交于 2019-12-05 21:42:27
问题 For a web app I'm making, I'm going to be getting text strings coming in, occasionally which contain quotation marks. Because I am then going to be document.writing the string, they need to be changed either into apostrophes or escaped. How would I do that, because when I try it doesn't seem to work, specifically I think because the string's quotation marks stop the rest of the script working. Hope that makes some sense, I'm quite new to this so that's why it might not make sense. I'll try

Python CSV : field containing quotation mark at the beginning

馋奶兔 提交于 2019-12-05 20:16:03
I am trying to read a CSV file containing a line like following: test,"test,"test,test,test,test There is a problems with the quotation marks (There are six fields, but they are retrieved as five fields, as "test,"test is read as a single field). I have tried modifying the entry as follows, but I still can't retrieve the quotation mark: test,""test,""test,test,test,test # quotation marks disappear when the entry is read. test,\"test,\"test,test,test,test # backslashes are also retrieved; escaping doesn't seem to work. I'm reading CSV file this way: info_source = csv.reader(open('.info.csv'),