Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h1>Description</h1> <p>Instead of capturing the individual quoted substrings like in your example, why not do this in one operation, where the offending strings are just replaced while ignoring the other ones.</p> <p>These expressions will:</p> <ul> <li>ignore escaped quotes like <code>"some \"text is quoted\" in here"</code></li> <li>find the desired <code>~::~</code> which are either inside or outside the quoted sections which is match is determined by the specific expression.</li> <li>assumes the input string already has properly balanced quotes</li> </ul> <p>Note the only difference is with the positive or negative lookahead</p> <p>Regex: <code>~::~(?!(?:(?:\\"|[^\\"])*(?:"(?:\\"|[^"])*){2})*$)</code> This finds the <code>~::~</code> which are <strong>in</strong> side quoted strings</p> <p>Regex: <code>~::~(?=(?:(?:\\"|[^\\"])*(?:"(?:\\"|[^"])*){2})*$)</code> This finds the <code>~::~</code> which are <strong>out</strong> side quoted strings, included here for extra credit but not demonstrated below.</p> <p>Replace with: empty string</p> <p><img src="https://i.stack.imgur.com/1AAYO.png" alt="enter image description here"></p> <h1>Example</h1> <p><a href="http://fiddle.re/nn85a" rel="nofollow noreferrer">Live Demo</a> In the example, you're interested in the "input.replace()" field which shows the output.</p> <p><strong>Sample Text</strong></p> <pre><code>~::~ aaa "bbb" "ccc ~::~ cc\"c ~::~ ccc" "ddd" ~::~ "eee" ~::~ </code></pre> <p><strong>After Replacement</strong></p> <pre><code>~::~ aaa "bbb" "ccc cc\"c ccc" "ddd" ~::~ "eee" ~::~ </code></pre> <h2><br></h2> <h1>Or</h1> <p>If you realy want to just capture the quoted strings while ignoring the escaped quotes then:</p> <p><code>"(?:\\"|[^"])*"</code></p> <p><img src="https://i.stack.imgur.com/Y0VDT.png" alt="enter image description here"></p> <h1>Example</h1> <p><strong>Sample Text</strong></p> <pre><code>~::~ aaa "bbb" "ccc ~::~ cc\"c ~::~ ccc" "ddd" ~::~ "eee" ~::~ </code></pre> <p><strong>Matches</strong></p> <pre><code>[0] =&gt; "bbb" [1] =&gt; "ccc ~::~ c\"cc ~::~ ccc" [2] =&gt; "ddd" [3] =&gt; "eee" </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

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