Python Regex findall But Not Including the conditional string
<p>i have this string:</p>

<p><code>The quick red fox jumped over the lazy brown dog lazy</code></p>

<p>And i wrote this regex which gives me this:</p>

<pre><code>s = The quick red fox jumped over the lazy brown dog lazy

re.findall(r'[\s\w\S]*?(?=lazy)', ss)
</code></pre>

<p>which gives me below output:</p>

<p><code>['The quick red fox jumped over the ', '', 'azy brown dog ', '']</code></p>

<p>But i am trying to get the output like this:</p>

<p><code>['The quick red fox jumped over the ']</code></p>

<p>Which means the regex should give me everything till it encounters the first <code>lazy</code> instead of last one and i only want to use <code>findall</code>.</p>

<p>Make the pattern <em>non-greedy</em> by adding a <code>?</code>:</p>

<pre><code>&gt;&gt;&gt; m = re.search(r'[\s\w\S]*?(?=lazy)', s)
#                            ^
&gt;&gt;&gt; m.group()
'The quick red fox jumped over the '
</code></pre>

python regex findall