Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Douglas Leeder's pattern (<code>(?:^|[^\\])'(([^\\']|\\'|\\\\)*)'</code>) will fail to match <code>"test 'test \x3F test' test"</code> and <code>"test \\'test' test"</code>. (String containing an escape other than quote and backslash, and string preceded by an escaped backslash.)</p> <p>cletus' pattern (<code>(?&lt;!\\)'((?:\\'|[^'])*)(?&lt;!\\)'</code>) will fail to match <code>"test 'test\\' test"</code>. (String ending with an escaped backslash.)</p> <p>My proposal for single-quoted strings is this:</p> <pre><code>(?&lt;!\\)(?:\\\\)*'((?:\\.|[^\\'])*)' </code></pre> <p>For both single-quoted or double-quoted stings, you could use this:</p> <pre><code>(?&lt;!\\)(?:\\\\)*("|')((?:\\.|(?!\1)[^\\])*)\1 </code></pre> <p>Test run using Python:</p> <pre><code>Doublas Leeder´s test cases: "''" matched successfully: "" " Example: 'Foo \' Bar' End. " matched successfully: "Foo \' Bar" "'\''" matched successfully: "\'" " Example2: 'Foo \\' End. " matched successfully: "Foo \\" "not matched\''a'" matched successfully: "a" "\''a'" matched successfully: "a" cletus´ test cases: "'testing 123'" matched successfully: "testing 123" "'testing 123\\'" matched successfully: "testing 123\\" "'testing 123" didn´t match, as exected. "blah 'testing 123" didn´t match, as exected. "blah 'testing 123'" matched successfully: "testing 123" "blah 'testing 123' foo" matched successfully: "testing 123" "this 'is a \' test'" matched successfully: "is a \' test" "another \' test 'testing \' 123' \' blah" matched successfully: "testing \' 123" MizardX´s test cases: "test 'test \x3F test' test" matched successfully: "test \x3F test" "test \\'test' test" matched successfully: "test" "test 'test\\' test" matched successfully: "test\\" </code></pre>
 

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