How do you strip quotes out of an ECHO’ed string in a Windows batch file?

The call command has this functionality built in. To quote the help for call: Substitution of batch parameters (%n) has been enhanced. You can now use the following optional syntax: %~1 – expands %1 removing any surrounding quotes (“) Here is a primitive example: @echo off setlocal set mystring=”this is some quoted text” echo mystring=%mystring% … Read more

Can JSON numbers be quoted?

In JSON, 6 is the number six. “6” is a string containing the digit 6. So the answer to the question “Can json numbers be quoted?” is basically “no,” because if you put them in quotes, they’re not numbers anymore. But, should the parsers accept both “attr” : 6 and “attr” : “6”? Yes, but … Read more

Backslashes in single quoted strings vs. double quoted strings

Double-quoted strings support the full range of escape sequences, as shown below: \a Bell/alert (0x07) \b Backspace (0x08) \e Escape (0x1b) \f Formford (0x0c) \n Newline (0x0a) \r Return (0x0d) \s Space (0x20) \t Tab (0x09) \v Vertical tab (0x0b) For single-quoted strings, two consecutive backslashes are replaced by a single backslash, and a backslash … Read more

Are single/double quotes allowed inside HTML attribute values?

Yes, both quotes are allowed in attribute values, but you must HTML-escape the quote you’re using as an attribute value delimiter, as well as other HTML-special characters like < and &: function encodeHTML(s) { return s.split(‘&’).join(‘&amp;’).split(‘<‘).join(‘&lt;’).split(‘”‘).join(‘&quot;’).split(“‘”).join(‘&#39;’); } var html=”<label my_attr=””+encodeHTML(attr_value)+'”>Text</label>’; However, you are usually much better off not trying to hack a document together from … Read more

PyYAML dump format

Below, ruamel.yaml is used instead. ruamel.yaml is actively maintained. Unlike PyYAML, ruamel.yaml supports: YAML <= 1.2. PyYAML only supports YAML <= 1.1. This is vital, as YAML 1.2 intentionally breaks backward compatibility with YAML 1.1 in several edge cases. This would usually be a bad thing. In this case, this renders YAML 1.2 a strict … Read more

How to handle double quotes in string before XPath evaluation?

PHP has Xpath 1.0, if you have a string with double and single quotes, a workaround is using the Xpath concat() function. A helper function can decide when to use what. Example/Usage: xpath_string(‘I lowe “double” quotes.’); // xpath: ‘I lowe “double” quotes.’ xpath_string(‘It\’s my life.’); // xpath: “It’s my life.” xpath_string(‘Say: “Hello\’sen”.’); // xpath: concat(‘Say: … Read more

Nesting quotes in JavaScript/HTML

You need to use proper escaping/encoding. Either in HTML using character references: <p onclick=”exampleFunc(‘&lt;div id=&quot;divId&quot;&gt;&lt;/div&gt;’);”>Some Text</p> Or in JavaScript using string escape sequences: <p onclick=”exampleFunc(‘\x3Cdiv\x20id\x3D\x22divId\x22\x3E\x3C/div\x3E’);”>Some Text</p>

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)