Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p><code>"[^\\']"</code><br> Second, the escaped apostrophe. Why would you need to escape the apostrophe?</p> </blockquote> <p>Firstly note that In Emacs regexp syntax, <code>\`</code> matches the start of the string, and <code>\'</code> matches the end of the string. In multi-line strings this is different to the more familiar <code>^</code> and <code>$</code>, which match the beginning of a line and the end of a line.</p> <p>However that is not relevant within a character alternative (square brackets), so this sequence is actually matching any character other than a backslash or an apostrophe.</p> <p><strong>Edit:</strong></p> <p>So from the comments, this is still causing confusion, so let's break it down:</p> <p><code>"'\\(?:[^\\']\\|\\(?:\\\\.\\)\\)*'"</code></p> <p>That code evaluates to this string/regexp:</p> <p><code>'\(?:[^\']\|\(?:\\.\)\)*'</code></p> <p><code>'</code> matches an apostrophe</p> <p><code>\(?:foo\)*</code> matches zero or more <code>foo</code></p> <p><code>foo\|bar</code> matches either of <code>foo</code> or <code>bar</code></p> <p><code>[^\']</code> matches any character other than a backslash or an apostrophe</p> <p><code>\(?:\\.\)</code> could (in this case, being a non-capturing group which occurs exactly once) be rewritten as simply <code>\\.</code>, and matches a backslash followed by any character other than a newline.</p> <p><code>'</code> matches an apostrophe</p> <p>So the whole thing matches a single-quoted string in which:</p> <ul> <li>any other single-quotes must each be preceded by a backslash</li> <li>any backslash must be paired with another non-newline character (which could also be a backslash)</li> </ul> <p>Which of course sounds like a typical string syntax in which backslashes can be used to escape special characters, including backslashes themselves and any instances of the delimiting quote character.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload