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>

How to escape history expansion exclamation mark ! inside a double quoted string?

In your last example, echo “$(echo ‘!b’)” the exclamation point is not single-quoted. Because history expansion occurs so early in the parsing process, the single quotes are just part of the double-quoted string; the parser hasn’t recognized the command substitution yet to establish a new context where the single quotes would be quoting operators. To … Read more