quotes

Passing a Batch File an Argument Containing a Quote Containing a Space

百般思念 提交于 2019-12-07 20:33:33
On many occasions I have dealt with passing batch files arguments with spaces, quotes, percents, and slashes and all sorts of combinations of them. Usually I managed to figure out how to accomplish what I want, but this time I am stuck. I have tried a couple of hundred combinations now and my head is starting to hurt. I’ve reduced the problem to a—fairly—simple requirement: pass from one batch file to another, an argument that contains some space-delimited text, one of which is a quoted space . That is, one batch file should pass some string X to another so that the the second one echos "A "B

JSON Encode and curly quotes

烈酒焚心 提交于 2019-12-07 13:56:10
问题 I've run into an interesting behavior in the native PHP 5 implementation of json_encode() . Apparently when serializing an object to a json string, the encoder will null out any properties that are strings containing "curly" quotes, the kind that would potentially be copy-pasted out of MS Word documents with the auto conversion enabled. Is this an expected behavior of the function? What can I do to force these kinds of characters to covert to their basic equivalents? I've checked for

When to wrap quotes around a shell variable?

送分小仙女□ 提交于 2019-12-07 09:22:35
问题 Could someone tell me whether or not I should wrap quotes around variables in a shell script? For example, is the following correct: xdg-open $URL [ $? -eq 2 ] or xdg-open "$URL" [ "$?" -eq "2" ] And if so, why? 回答1: General rule: quote it if it can either be empty or contain spaces (or any whitespace really) or special characters (wildcards). Not quoting strings with spaces often leads to the shell breaking apart a single argument into many. $? doesn't need quotes since it's a numeric value.

Inno Setup, spaces and double quote in [Run]

五迷三道 提交于 2019-12-07 06:30:23
问题 I'm trying to schedule a task on Windows, and unfortunately, it doesn't work! The task is created but not correctly. When I look into task's parameters, it says: PROGRAM: C:\Program ARGUMENTS: Files(x86)\AppName\executable.exe This is how I proceed: [Run] Filename: "schtasks.exe"; Parameters: "/create /tn TaskName /sc MINUTE /mo 10 /tr ""{app}\{#MyAppExeName}"""; And I don't know why it doesn't work, doubles quotes should fix the "spaces problem" Any ideas? 回答1: This problem is known and is

Regular Expression to escape double quotes inside single quotes

China☆狼群 提交于 2019-12-06 13:02:31
问题 I would need a regular expression that escapes or captures (if not already escaped) ALL the double quote characters INSIDE a single quoted string and then convert the opening single quotes to double quotes! We are refactoring files that have a lot (and i mean a lot!) of single quoted strings in either PHP and also JS files. The only thing they have in common is that the strings are at least in one line and are concated with = in both languages. I give an example ( the example is ugly legacy

Messy &quot returned from Rails 3 controller to view

我的未来我决定 提交于 2019-12-06 12:13:20
问题 On my Rails 3 app controller I have the following code: array = [] Location.all.each{|x|array<<x.city.html_safe} @data_dump = array In the Rails console it looks nice and clean: ["Littelside", "Tessmouth"] In my view the @data_dump object gets encoded: ["Littelside", "Tessmouth"] How do you clean this mess up? I want my object in view, to return as the object does in terminal. Thanks in advance! 回答1: What about: <%=raw @data_dump %> 来源: https://stackoverflow.com/questions/6131347/messy-quot

Why does PowerShell not recognize quoted parameters?

早过忘川 提交于 2019-12-06 09:53:20
Why does PowerShell treat quoted parameters differently when you invoke the script directly (in a PowerShell console or ISE) or when you invoke it via another PowerShell instance? Here is the script ( TestQuotes.ps1 ): param ( [string] $Config = $null ) "Config = $Config" Here are the results: PS D:\Scripts> .\TestQuotes.ps1 -Config "A B C" Config = A B C PS D:\Scripts> PowerShell .\TestQuotes.ps1 -Config "A B C" Config = A PS D:\Scripts> .\TestQuotes.ps1 -Config 'A B C' Config = A B C PS D:\Scripts> PowerShell .\TestQuotes.ps1 -Config 'A B C' Config = A Any ideas? According to the PowerShell

How to deal with quotes and apostrophes for string comparison in MySQL so they match (collation)

拈花ヽ惹草 提交于 2019-12-06 08:19:44
问题 MySQL uses collations to do string comparison because some characters should match Exemple: SELECT 'é' = 'e' COLLATE utf8_unicode_ci; SELECT 'oe' = 'œ' COLLATE utf8_unicode_ci; both return true Now, how can I do the same with quotes (') vs apostrophes (’) This is not the same character, the proper character to use when writing “it’s” or “l’oiseau” (in french) are both the apostrophe. The fact is that neither utf8_general_ci or utf8_unicode_ci collate them. The easy solution is to store

Replace part of string between quotes in php regex

徘徊边缘 提交于 2019-12-06 04:49:32
Now I've got very basic regex skills, only used regex a couple of times for basic stuff. This has probably been asked before, which I apologize for, but I couldn't find any answer for this. Found similar, though and tried to adapt it but to no avail. OK, to the question - How do I replace a space only between certain characters (doublequotes in this case)? Say i have the following string: "mission podcast" modcast A B C "D E F" I want to replace the spaces between mission and podcast as well as the ones between D , E & F whilst leaving the other ones untouched. P.S. What if space was a string?

Removing hash comments that are not inside quotes

被刻印的时光 ゝ 提交于 2019-12-06 04:38:52
问题 I am using python to go through a file and remove any comments. A comment is defined as a hash and anything to the right of it as long as the hash isn't inside double quotes . I currently have a solution, but it seems sub-optimal: filelines = [] r = re.compile('(".*?")') for line in f: m = r.split(line) nline = '' for token in m: if token.find('#') != -1 and token[0] != '"': nline += token[:token.find('#')] break else: nline += token filelines.append(nline) Is there a way to find the first