Note that there are some explanatory texts on larger screens.

plurals
  1. POREGEXP: capture group NOT followed by
    text
    copied!<p><strong>I need to match following statements:</strong></p> <pre><code>Hi there John Hi there John Doe (jdo) </code></pre> <p><strong>Without matching these:</strong></p> <pre><code>Hi there John Doe is here Hi there John is here </code></pre> <p>So I figured that this regexp would work:</p> <pre><code>^Hi there (.*)(?! is here)$ </code></pre> <p>But it does not - and I am not sure why - I believe this may be caused by the capturing group (.*) so i thought that maybe making * operator lazy would solve the problem... but no. This regexp doesn't work too:</p> <pre><code>^Hi there (.*?)(?! is here)$ </code></pre> <p>Can anyone point me in the solutions direction?</p> <h1>Solution</h1> <p>To retrieve sentence <strong>without</strong> <code>is here</code> at the end (like <code>Hi there John Doe (the second)</code>) you should use (author @Thorbear):</p> <pre><code>^Hi there (.*$)(?&lt;! is here) </code></pre> <p>And for sentence that contains some data in the middle (like <code>Hi there John Doe (the second) is here</code>, <em>John Doe (the second)</em> being the desired data)simple grouping would suffice:</p> <pre><code>^Hi there (.*?) is here$ </code></pre> <p>.</p> <pre><code> ╔══════════════════════════════════════════╗ ║▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒║ ║▒▒▒Everyone, thank you for your replies▒▒▒║ ║▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒║ ╚══════════════════════════════════════════╝ </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