Not in regular expression not working
<p>I am trying to make a regular expression that matches a line when it has a number followed by a ok word.</p>

<p>Eg:</p>

<pre><code>10 ok
</code></pre>

<p>But if there is a number and nok after the ok word, then it should not match.
Eg:</p>

<pre><code>10 ok    2 nok
</code></pre>

<p>I am using the following regular expression to achieve this:</p>

<pre><code>[0-9]+\s+ok\s+(?!([0-9]+\s+nok))
</code></pre>

<p>I am using the 4th answer from <a href="https://stackoverflow.com/questions/5925738/which-regular-expression-operator-means-dont-match-this-character">Which regular expression operator means &#39;Don&#39;t&#39; match this character?</a> to generate a <code>not</code> functionality in my regex.</p>

<p>Here is my code:</p>

<pre><code>import re

prog=re.compile('[0-9]+\s+ok\s+(?!([0-9]+\s+nok))')
result=prog.search('108601                  ABC_kill                            11 ok  3 nok        95m   25_KLPO   casdas5  dus41  fdd     tm500  sdfsd1010_1014             2m    2016-02-11 02:30:50  2016-02-11 08:53:59')

print (result)
</code></pre>

<p>But my pattern still matches with a line that contains <code>nok</code></p>