Single quote escape in JavaScript function parameters

JSON.stringify(plainTextStr).replace(/&/, “&”).replace(/”/g, “"”) will produce a string you can safely embed in a quoted attribute and which will have the same meaning when seen by the JavaScript interpreter. The only caveat is that some Unicode newlines (U+2028 and U+2029) need to be escaped before being embedded in JavaScript string literals, but JSON only requires that … Read more

How to escape single quote in sed?

Quote sed codes with double quotes: $ sed “s/ones/one’s/”<<<“ones thing” one’s thing I don’t like escaping codes with hundreds of backslashes – hurts my eyes. Usually I do in this way: $ sed ‘s/ones/one\x27s/'<<<“ones thing” one’s thing

When to use ‘ (or quote) in Lisp?

Short answer Bypass the default evaluation rules and do not evaluate the expression (symbol or s-exp), passing it along to the function exactly as typed. Long Answer: The Default Evaluation Rule When a regular (I’ll come to that later) function is invoked, all arguments passed to it are evaluated. This means you can write this: … Read more